singleflight

Types

pub type Config {
  Config(initialisation_timeout_ms: Int, fetch_timeout_ms: Int)
}

Constructors

  • Config(initialisation_timeout_ms: Int, fetch_timeout_ms: Int)
pub type Message(k, v) {
  Request(key: k, work: fn(k) -> v, caller: process.Subject(v))
  Done(key: k, result: v)
}

Constructors

  • Request(key: k, work: fn(k) -> v, caller: process.Subject(v))
  • Done(key: k, result: v)
pub opaque type Singleflight(k, v)

Values

pub fn config(
  initialisation_timeout_ms: Int,
  fetch_timeout_ms: Int,
) -> Config
pub fn fetch(
  singleflight: Singleflight(k, v),
  key: k,
  work: fn(k) -> v,
) -> v
pub fn start(
  config: Config,
  name: process.Name(Message(k, v)),
) -> Result(actor.Started(Singleflight(k, v)), actor.StartError)
Search Document