<div dir="ltr"><div>Hello Moritz,</div><div><br></div><div>Indeed, the auto-update do not do any refresh if the returned action is not called.</div><div>So in your case your token will expire, which is not the desired behavior.</div><div><br></div><div>From the same package, you have Reaper <a href="https://hackage.haskell.org/package/auto-update-0.1.4/docs/Control-Reaper.html">https://hackage.haskell.org/package/auto-update-0.1.4/docs/Control-Reaper.html</a> <br></div><div>which allow you to run periodically an action on an associated resource while still providing the possibility to read and append from this resource.</div><div><br></div><div>In your case it should fit by using the clean action as the refresh job, and using reaperRead to get your token.</div><div> While this being said, using reaper may be a bit far fetched so using async-refresh or pollT may be a better call :)<br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-11-25 23:53 GMT+01:00 Moritz Schulte <span dir="ltr"><<a href="mailto:mtesseract@silverratio.net" target="_blank">mtesseract@silverratio.net</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Erèbe,<br>
<br>
Thanks for the suggestion.<br>
<br>
I've only had a very quick look at the auto-update package, so please<br>
correct me if I'm wrong. But I think there is an important difference<br>
between auto-update and the suggested pollT (or the async-refresh<br>
package):<br>
<br>
auto-update does not completely decouple the execution of the IO<br>
action from the calling thread. I'm referring to this comment:<br>
<br>
   mkAutoUpdate :: UpdateSettings a -> IO (IO a)<br>
<br>
   Generate an action which will either read from an automatically<br>
   updated value, **or run the update action in the current thread**.<br>
<br>
pollT and async-refresh are implemented such that the caller really<br>
only retrieves the result of a previously executed IO action.  Thus<br>
even if the IO action might block, the caller does basically not block<br>
(more than required for reading a TVar).<br>
<br>
For the use case it was created for (refreshing of authentication<br>
tokens in a micro service) it might be very important that the<br>
required tokens are *always* guaranteed to be available already at the<br>
time a request needs to be made.<br>
<br>
But maybe I'm overlooking something and auto-update does indeed also<br>
provide this functionality.<br>
<br>
Best,<br>
Moritz<br>
<div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/haskell-<wbr>cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</div></div></blockquote></div><br></div>