Commit graph

157 commits

Author SHA1 Message Date
dc0ba2984e Retry when server responds 503 too.
That's "Service Unavailable", it's
probably a temporary failure.
2020-10-20 22:20:19 +02:00
7d1011405a More readme 2020-09-15 01:35:16 +02:00
2534e5896c Add build instructions to readme 2020-09-15 01:17:25 +02:00
66e8406689 Delete code that was committed by mistake 2020-09-15 00:51:02 +02:00
cb12f5c025 Some small fixes 2020-09-15 00:46:18 +02:00
36b0c6f6f0 Add retry capability on connection errors
This fixes bug #2
2020-09-15 00:45:39 +02:00
2c8e557bb4 Throw when content-type is not application/json 2020-09-12 01:48:10 +01:00
6bafd923f3 Import mime_split from tawashi (kamokan) 2020-09-12 01:32:08 +01:00
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