package shared-block-ring

  1. Overview
  2. Docs

Module Make.ProducerSource

include S.RING with type disk := B.t with type item = Item.t
Sourcetype t
Sourcetype item = Item.t
Sourcetype error = [
  1. | `Retry
  2. | `Suspended
  3. | `Msg of string
]
Sourcetype 'a result = ('a, error) Result.result
Sourceval pp_error : Format.formatter -> error -> unit
Sourceval open_error : 'a result -> ('a, [> error ]) Result.result
Sourceval error_to_msg : 'a result -> ('a, S.msg) Result.result
Sourceval attach : ?queue:string -> ?client:string -> disk:B.t -> unit -> t result Lwt.t

attach queue client blockdevice attaches to a previously-created shared ring on top of blockdevice.

Sourceval detach : t -> unit Lwt.t

detach t frees all resources associated with t. Attempts to use t after a detach will result in an `Error _

Sourceval state : t -> [ `Running | `Suspended ] result Lwt.t

state t () queries the current state of the ring. If the result is `Suspended then the producer has acknowledged and will nolonger produce items. Clients which support suspend/resume should arrange to call this function periodically.

Sourceval debug_info : t -> (string * string) list result Lwt.t

debug_info t returns a list of key=value pairs which may be useful for debugging. Nothing should be assumed about the keys or the values; they should only be printed or logged.

Sourcetype position

The position within a stream

Sourceval sexp_of_position : position -> Sexplib0.Sexp.t
include S.COMPARABLE with type t := position
Sourceval compare : position -> position -> [ `LessThan | `Equal | `GreaterThan ]

Compare two items

Sourceval advance : t:t -> position:position -> unit -> unit result Lwt.t

advance t position exposes the item associated with position to the Consumer so it can be popped.

Sourceval create : disk:B.t -> unit -> unit result Lwt.t

create blockdevice initialises a shared ring on top of blockdevice where we will be able to push variable-sized items.

Sourceval push : t:t -> item:item -> unit -> position result Lwt.t

push t item pushes item onto the ring t but doesn't expose it to the Consumer. `Ok position means the update has been safely written to the block device and can be exposed to the Consumer by calling advance position. `Error message indicates some fatal software bug: the message should be logged and the process shutdown. `Suspend means that the consumer has requested that no more items be pushed onto the queue temporarily `Retry means that the item should fit but there is temporarily not enough space in the ring. The client should retry later.

OCaml

Innovation. Community. Security.