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.
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.
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
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.
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.
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.
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.