Module Async_durable__.Durable
val create : to_create:(unit -> 'a Async_kernel.Deferred.Or_error.t) -> is_broken:('a -> bool) -> ?to_rebuild:('a -> 'a Async_kernel.Deferred.Or_error.t) -> unit -> 'a tto_createtells the Durable how to build a fresh 'a value.is_brokentests whether the current 'a value can be used. It should return true when you want the Durable to attempt to rebuild or recreate the 'a.to_rebuildIs called on the broken 'a. It should return a "fixed" 'a.When the function
with_below is called, it usesis_brokento test if the current Durable value is broken. If not, it calls eitherto_createorto_rebuild. Ifto_rebuildis None (as in the default case), the Durable will try to create a fresh value withto_create.createdoes not create the Durable value. The first call toto_createwill be made on the first use ofwith_.
val create_or_fail : to_create:(unit -> 'a Async_kernel.Deferred.Or_error.t) -> is_broken:('a -> bool) -> ?to_rebuild:('a -> 'a Async_kernel.Deferred.Or_error.t) -> unit -> 'a t Core_kernel.Or_error.t Async_kernel.Deferred.tcreate_or_failimmediately callsto_create, returning an error if that first attempt fails. This function will also return an error if the initial durable value is broken.
val with_ : 'a t -> f:('a -> 'b Async_kernel.Deferred.Or_error.t) -> 'b Async_kernel.Deferred.Or_error.twith_applies the given function to the Durable value ifis_brokenreturns false. Ifis_brokenreturn true, it first callsto_createorto_rebuild. This function will return an error if eitherto_createorto_rebuildreturns an error, or if the rebuilt or recreated durable value is broken.is_brokenis checked immediately before callingf.We will only make one attempt to rebuild a broken value. If a call to
to_rebuildreturnsError _, we will drop the previously built value. The next call towith_will callto_create.with_will raise iffraises.