[Haskell-cafe] Running an action periodically
nemesia.lilith at gmail.com
Sat Nov 25 23:37:43 UTC 2017
Indeed, the auto-update do not do any refresh if the returned action is not
So in your case your token will expire, which is not the desired behavior.
>From the same package, you have Reaper
which allow you to run periodically an action on an associated resource
while still providing the possibility to read and append from this resource.
In your case it should fit by using the clean action as the refresh job,
and using reaperRead to get your token.
While this being said, using reaper may be a bit far fetched so using
async-refresh or pollT may be a better call :)
2017-11-25 23:53 GMT+01:00 Moritz Schulte <mtesseract at silverratio.net>:
> Hi Erèbe,
> Thanks for the suggestion.
> I've only had a very quick look at the auto-update package, so please
> correct me if I'm wrong. But I think there is an important difference
> between auto-update and the suggested pollT (or the async-refresh
> auto-update does not completely decouple the execution of the IO
> action from the calling thread. I'm referring to this comment:
> mkAutoUpdate :: UpdateSettings a -> IO (IO a)
> Generate an action which will either read from an automatically
> updated value, **or run the update action in the current thread**.
> pollT and async-refresh are implemented such that the caller really
> only retrieves the result of a previously executed IO action. Thus
> even if the IO action might block, the caller does basically not block
> (more than required for reading a TVar).
> For the use case it was created for (refreshing of authentication
> tokens in a micro service) it might be very important that the
> required tokens are *always* guaranteed to be available already at the
> time a request needs to be made.
> But maybe I'm overlooking something and auto-update does indeed also
> provide this functionality.
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe