Timeout consistency
Here is an attempt at fixing #63 by introducing timeouts for the BGG cache at two places:
- Total time spent in
retrieveBGGThings
, including all chunks. - Total time spent in
requestBGG
, including all retries.
Other changes are:
- Reworked chunking so that it is possible to make partial progress in refreshing the cache even if there is a timeout.
- Unfortunately, I had to intertwine request logic and caching logic for this.
- For now, the combined logic is in the BGG module, but we could consider reworking the cache module as a cache implementation that takes care of timeouts and chunking as well.
- Reworked the delay logic because the
timeout
function didn't seem to play well with forking a thread that modifies aTMVar
after some time. (The forked thread seemed to die without our code being able to catch an exception, so I couldn't find a way to "release the request lock" on timeout.) - Made retrieval of BGG IDs from all instances a periodic action.
- (Fixed parsing of time configuration.)
While this solution seems to work, it is rather hacky, so I'm open to suggestions for improvement and even completely different approaches. One thing I thought of was specifying the timeout "dynamically" whenever retrieveBGGThings
is called in a Snap handler, but I couldn't find a find an easy way of getting the "remaining time" in a Snap handler (and didn't bother to do the time tracking in our code).
Edited by Aras Ergus