Commit graph

138 commits

Author SHA1 Message Date
3dc0f849b5 Fix bug with ~Event() calling a virtual method
This solves a crash when an exception is thrown
on the main thread (in test() for example, when
setting json storage to xz but without liblzma
support enabled).
Thi also makes the program quit gracefully when
SIGINT is received.
It seems to also fix the problem with exceptions
thrown in worker threads.
2020-09-05 17:09:01 +01:00
a32044a4b5 Add optional lzma support for stored json responses
When enabled entries in the DB are stored as base64
encoded xz data. To uncompress save to a file
my_json.base64 and run:

cat my_json.base64 | base64 --decode | unxz --decompress - > my_json.txt
2020-09-05 14:00:22 +01:00
2e25008de3 Timeouts should be treated as integer here
It's not a double in the settings. It gets casted into
a double later, but it's not like you can set 3.528 in
the settings.
2020-09-05 12:25:12 +01:00
d19b81a54e Increase max delay from 1 to 10 days 2020-09-05 03:17:46 +01:00
406cd80a2e Update some settings 2020-09-05 03:17:19 +01:00
78a933a101 Version bump to 0.2.0 2020-09-05 02:49:39 +01:00
8be26c2d1c Improve update interval calculation 2020-09-05 02:49:39 +01:00
200c74757d Not sure but maybe this should be set_exception()? 2020-09-05 02:15:01 +01:00
baf0256f84 Store next access time in the db when server returns 429 2020-09-05 02:14:42 +01:00
e24ebcf8e8 Add timeout options to config file
This allows users to specify the minimum wait for each
request. The (currently wrong) estimate of
retry_after / rate_limit is calculated, and the max
between that and the setting in the config file is
used.
2020-09-05 01:36:26 +01:00
7da3f81c27 Fix insertion of empty item record
Also improve some code style a bit
2020-09-05 01:00:25 +01:00
8f8865e4df Pass app_config to test() instead of single options 2020-09-05 00:59:51 +01:00
9d4d52bed0 Add store_raw_json option to config 2020-09-05 00:41:01 +01:00
3b071727c3 Properly use the extra delay in all cases 2020-09-04 15:10:24 +01:00
a5e2c14171 Rename header to header_list 2020-09-04 15:09:08 +01:00
f8fde74b84 Rename section "rules" to "options" 2020-09-04 15:06:17 +01:00
d1573c6218 Header entries should be case insensitive 2020-09-04 02:29:26 +01:00
9dffbf811c Throw an exception when response is not 200 OK
Not sure this is the best way to do this, but
at least I'm not just ignoring errors now.
2020-09-04 01:56:38 +01:00
c98083837d Fix for the new server's reply
Just when I was about to deploy it they changed the
server to return HTTP/2... lol
No big deal (I think), fix the http header parser so
if the "OK" message string is missing it'll keep
parsing.
2020-09-04 01:17:59 +01:00
b768015b52 Implement ApiNap::fame_list() 2020-09-04 00:58:12 +01:00
571a92aa2e Implement ApiNap::market_list() 2020-09-04 00:58:12 +01:00
1cb40fd5ba Replace string_view with string
In datatypes.cpp function to_timestamp() the
istringstream needs a string, so passing
a string_view around is pointless.
2020-09-04 00:05:19 +01:00
8ca23eb221 Implement ApiNap::items_icons() 2020-09-03 23:51:38 +01:00
d66c020ad8 Implement ApiNap::items_list() 2020-09-03 23:47:33 +01:00
2aaf500b66 Implement ApiNap::WhoAmI()
Refactor code out into fetch_and_parse() since the
two functions were pretty much the copy paste of
the other. This should simplify the rest of the
missing implementations too.
2020-09-03 23:04:41 +01:00
3ff82985c9 Implement ApiNap::ping() 2020-09-03 01:59:33 +01:00
99d577f43a Bugfix in HttpResponse
string_views are potentially wrong if raw is very small
and stdlib has small string optimisation. Use unique_ptr
instead to force allocations in all cases.
2020-09-03 00:55:16 +01:00
5342185370 Build fix for systems without libev in pkg-config 2020-08-29 19:32:18 +01:00
d433e05877 Change restc-cpp into a meson wrap (lest too) 2020-08-29 18:03:04 +01:00
32dea4d089 Add virtual do destructor 2020-08-29 17:20:05 +01:00
4e63e1b246 Make Api virtual.
I think this is a bit better than what I had before.
Still a mess, but that's conditional compilation for you.
2020-08-29 17:10:41 +01:00
80bfbc640a Add option to choose between restc-cpp and nap
I don't think this is very clean, but they might fix
the bug in restc-cpp that is currently holding this
project back, and I might want to go back to it.
I might refactor this into a virtual class.
2020-08-29 16:42:34 +01:00
8b09d7da53 Store headers as string lines
curl ultimately expects null-terminated strings and
makes a copy of each, so it's pointless to mess
around with string_views and stuff if I have to make
a copy for curl at the end anyways.
2020-08-29 15:18:33 +01:00
bc6b20563b Send user specified headers with the request 2020-08-29 14:30:08 +01:00
74e98211a7 Start working on QuickRest 2020-08-29 14:28:47 +01:00
c4935ac70d Move rest stuff into nap subdir.
Nap is a quick REST. Silly joke really, but hey, 3 letters.
Great namespace name.
2020-08-29 12:34:55 +01:00
05c03c2daf Working on a replacement for restc-cpp 2020-08-29 01:54:52 +01:00
440fbd52b9 Don't install unnecessary files 2020-08-28 01:35:07 +01:00
85f7ac321e Add simdjson wrap file and meson scripts 2020-08-28 01:07:12 +01:00
6b41e08403 Fix SQLiteCpp meson scripts. 2020-08-28 00:13:13 +01:00
ada38348ee Change SQLiteCpp into a wrap file 2020-08-28 00:04:31 +01:00
e856918963 Add curlcpp subproject 2020-08-27 23:55:15 +01:00
5ef7a880e0 Get rid of redundant if 2020-08-27 17:39:06 +01:00
2c36e6794e Use the if_found feature for subdir() 2020-08-27 16:08:06 +01:00
be1a19f7c7 Move backend name to config file
Still, only one backend is available at this point.
2020-08-22 02:30:00 +01:00
c5e0b01b06 Add OriginsDB base class and a make() function
This fixes the build. The make function for the moment
just takes a string since that's all that's ever needed.
This is supposed to change since the postgresql database
will need a port, an url, password etc. Maybe
connection strings are still a thing, but if not then
I'll probably need to find a way to accept arbitrary
parameters in OriginsDB::make().
2020-08-22 01:57:14 +01:00
217c844893 Move OriginsDB sqlite files
This breaks the build
2020-08-22 01:53:04 +01:00
2a407294e1 Add an option to enable/disable sqlite backend
Currently you can't disable it since sqlite is the only
supported backend and you must have at least one enabled
and available on the system. This will be needed for later.
2020-08-22 01:30:04 +01:00
4b641e7976 Fix restc-cpp unit test's build 2020-08-22 00:50:56 +01:00
6dc4c3133f Import cmake unit test to restc-cpp 2020-08-21 21:16:05 +01:00