package tezos-workers

  1. Overview
  2. Docs

Parameters

Signature

module Name = Name
module Event = Event
module Request = Request
module Types = Types
type 'kind t

A handle to a specific worker, parameterized by the type of internal message buffer.

type 'kind table

A handle to a table of workers.

type 'a queue

Internal buffer kinds used as parameters to t.

and bounded
and infinite
type dropbox
type _ buffer_kind =
  1. | Queue : infinite queue buffer_kind
  2. | Bounded : {
    1. size : int;
    } -> bounded queue buffer_kind
  3. | Dropbox : {
    1. merge : dropbox t -> any_request -> any_request option -> any_request option;
    } -> dropbox buffer_kind

Supported kinds of internal buffers.

and any_request =
  1. | Any_request : _ Request.t -> any_request
val create_table : 'kind buffer_kind -> 'kind table

Create a table of workers.

module type HANDLERS = sig ... end

The callback handlers specific to each worker instance.

val launch : 'kind table -> ?timeout:Tezos_base.Time.System.Span.t -> Tezos_base.Worker_types.limits -> Name.t -> Types.parameters -> (module HANDLERS with type self = 'kind t) -> ('kind t, Tezos_error_monad.TzCore.error list) Stdlib.result Lwt.t

Creates a new worker instance. Parameter queue_size not passed means unlimited queue.

val shutdown : _ t -> unit Lwt.t

Triggers a worker termination and waits for its completion. Cannot be called from within the handlers.

module type BOX = sig ... end

The following interface are common elements of multiple modules below. They are used to minimize repetition.

module type QUEUE = sig ... end
module type BOUNDED_QUEUE = sig ... end
module Dropbox : sig ... end
module Queue : sig ... end
val protect : _ t -> ?on_error: (Tezos_error_monad.TzCore.error list -> ('b, Tezos_error_monad.TzCore.error list) Stdlib.result Lwt.t) -> (unit -> ('b, Tezos_error_monad.TzCore.error list) Stdlib.result Lwt.t) -> ('b, Tezos_error_monad.TzCore.error list) Stdlib.result Lwt.t

Detects cancellation from within the request handler to stop asynchronous operations.

val canceler : _ t -> Lwt_canceler.t

Exports the canceler to allow cancellation of other tasks when this worker is shutdown or when it dies.

val trigger_shutdown : _ t -> unit

Triggers a worker termination.

val record_event : _ t -> Event.t -> unit

Record an event in the backlog.

val log_event : _ t -> Event.t -> unit Lwt.t

Record an event and make sure it is logged.

val state : _ t -> Types.state

Access the internal state, once initialized.

val last_events : _ t -> (Tezos_event_logging.Internal_event.level * Event.t list) list

Access the event backlog.

val pending_requests : _ queue t -> (Tezos_base.Time.System.t * Request.view) list

Introspect the message queue, gives the times requests were pushed.

Get the running status of a worker.

val current_request : _ t -> (Tezos_base.Time.System.t * Tezos_base.Time.System.t * Request.view) option

Get the request being treated by a worker. Gives the time the request was pushed, and the time its treatment started.

val view : _ t -> Types.view

Introspect the state of a worker.

val list : 'a table -> (Name.t * 'a t) list

Lists the running workers in this group.

val find_opt : 'a table -> Name.t -> 'a t option

find_opt table n is Some worker if the worker is in the table and has name n.

OCaml

Innovation. Community. Security.