package shared-block-ring

  1. Overview
  2. Docs

Create a journal from a block device. Descriptions of idempotent operations may be pushed to the journal, and we guarantee to perform them at-least-once in the order they were pushed provided the block device is available. If the program crashes, the journal replay will be started when the program restarts.

Parameters

module Log : S.LOG
module Block : S.BLOCK
module Time : S.TIME
module Clock : S.CLOCK

Signature

type t

A journal kept on disk of work we need to perform

type error = [
  1. | `Msg of string
]
type 'a result = ('a, error) Result.result
val pp_error : Stdlib.Format.formatter -> error -> unit
val open_error : 'a result -> ('a, [> error ]) Result.result
val error_to_msg : 'a result -> ('a, S.msg) Result.result
val start : ?name:string -> ?client:string -> ?flush_interval:int64 -> ?retry_interval:int64 -> Block.t -> (Operation.t list -> unit result Lwt.t) -> t result Lwt.t

Start a journal replay thread on a given disk, with the given processing function which will be applied at-least-once to every item in the journal. If a flush_interval is provided then every push will start a timer and the items will not be processed until the timer expires (or the journal becomes full) to encourage batching. The retry_interval gives the delay between re'perform'ing journalled items that fail. Default is 5 seconds.

val shutdown : t -> unit Lwt.t

Shut down a journal replay thread

type waiter = {
  1. flush : unit -> unit;
  2. sync : unit -> unit Lwt.t;
}
val push : t -> Operation.t -> waiter result Lwt.t

Append an operation to the journal. When this returns, the operation will be performed at-least-once before any later items are performed. If a client needs to wait for the operation to be completed then call the returned thunk and wait for the resulting thread.

OCaml

Innovation. Community. Security.