UpdatesBuilder

class UpdatesBuilder[F[_], A] extends RefreshableBuilder[F, A]

Caches a single instance of type A for a period of time before refreshing it automatically.

The time between refreshes is dynamic and based on the value of each A itself. This is similar to RefreshableEffect except that only exposes a fixed refresh frequency.

As well as the time between refreshes, the retry policy is also dynamic and based on the value for A. This allows you to configure the policy based on when A is going to expire.

You can use the cacheDuration and retryPolicy together to eagerly fetch a new value for A using the calculated cache duration minus some duration to allow for retries and then set the retry policy to retry throughout that duration.

An old value is only made unavailable after a new value has been acquired. This means that the time each value is exposed for is cacheDuration plus the time to evaluate fa.

Value parameters:
cacheDuration

how long to cache a newly generated value of A for, if an effect is needed to generate this duration it should have occurred in fa. Defaults to defaultCacheDuration if not specified.

defaultValue

an optional default value to use when initialising the resource, if the call to fa fails. This will prevent the constructor from failing during startup

exhaustedRetriesCallback

what to do if retrying to refresh the value fails. The refresh fiber will have failed at this point and the value will grow stale. It is up to user handle this failure, as they see fit, in their application

newValueCallback

a callback invoked whenever a new value is generated, the scala.concurrent.duration.FiniteDuration is the period that will be waited before the next new value

refresh

generate a new value of A

refreshFailureCallback

what to when an attempt to refresh the value fails, fa will be retried according to retryPolicy

retryPolicy

a function to derive a configuration object for attempting to retry the effect of fa on failure from the current value of A. Defaults to defaultRetryPolicy when not specified

Source:
Refreshable.scala
class RefreshableBuilder[F, A]
class Object
trait Matchable
class Any

Value members

Concrete methods

override def cacheDuration(cacheDuration: A => FiniteDuration): UpdatesBuilder[F, A]
Definition Classes
Source:
Refreshable.scala
override def defaultValue(defaultValue: A): UpdatesBuilder[F, A]
Definition Classes
Source:
Refreshable.scala
override def onExhaustedRetries(callback: PartialFunction[Throwable, F[Unit]]): UpdatesBuilder[F, A]
Definition Classes
Source:
Refreshable.scala
override def onNewValue(callback: (A, FiniteDuration) => F[Unit]): UpdatesBuilder[F, A]
Definition Classes
Source:
Refreshable.scala
override def onRefreshFailure(callback: PartialFunction[(Throwable, RetryDetails), F[Unit]]): UpdatesBuilder[F, A]
Definition Classes
Source:
Refreshable.scala
override def resource: Resource[F, Updates[F, A]]
Definition Classes
Source:
Refreshable.scala
override def retryPolicy(retryPolicy: A => RetryPolicy[F]): UpdatesBuilder[F, A]
Definition Classes
Source:
Refreshable.scala
override def retryPolicy(retryPolicy: RetryPolicy[F]): UpdatesBuilder[F, A]
Definition Classes
Source:
Refreshable.scala
override def withUpdates: UpdatesBuilder[F, A]
Definition Classes
Source:
Refreshable.scala