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 FetchError {
Crashed
TimedOut
}
Constructors
-
Crashed -
TimedOut
pub type FetchResult(v) =
Result(v, FetchError)
pub type Message(k, v) {
Request(
key: k,
work: fn(k) -> v,
caller: process.Subject(Result(v, FetchError)),
)
Done(pid: process.Pid, key: k, result: Result(v, FetchError))
WorkerDown(pid: process.Pid)
}
Constructors
-
Request( key: k, work: fn(k) -> v, caller: process.Subject(Result(v, FetchError)), ) -
Done(pid: process.Pid, key: k, result: Result(v, FetchError)) -
WorkerDown(pid: process.Pid)
pub opaque type Singleflight(k, v)
Values
pub fn fetch(
singleflight: Singleflight(k, v),
key: k,
work: fn(k) -> v,
) -> Result(v, FetchError)
pub fn start(
config: Config,
name: process.Name(Message(k, v)),
) -> Result(actor.Started(Singleflight(k, v)), actor.StartError)