Commit graph

149 commits

Author SHA1 Message Date
ad3bdd0f37 Add some debug verbosity 2020-09-12 00:41:44 +01:00
8701b5aef3 Update source_id in fame_list table 2020-09-12 00:41:02 +01:00
497d797e32 Quit cleanly when an exception is thrown
The trick is to break the ev loop from within its
same thread. This can be done with the async event
for example, so I repurposed the one I already had
to call stop() in case an error has been set.
Otherwise its callback is a no-op just like before.
2020-09-12 00:40:41 +01:00
4cb47eb82e Update readme 2020-09-11 22:36:13 +01:00
317e8a3398 Embed try/catch/set_exception into the pool itself 2020-09-08 21:35:50 +01:00
6543f31acb fix sql query to only consider vending shops 2020-09-07 01:57:43 +01:00
ce4753fd6d Add initial readme file 2020-09-07 01:45:40 +01:00
a99976a242 Small cleaning 2020-09-06 17:47:54 +01:00
41eeee4e69 Install config file to etc
Only install if sysconfdir is not the same as the
source config file from the source directory.
2020-09-06 17:43:32 +01:00
2221aef77c Throw if api key looks wrong 2020-09-06 17:10:57 +01:00
abc5441a50 Only print ping stuff in debug 2020-09-06 17:10:35 +01:00
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