Up

Module Make (S : Worker_spec) : Worker with type 'a functions := 'a S.functions and type worker_state_init_arg := S.Worker_state.init_arg and type connection_state_init_arg := S.Connection_state.init_arg

module Worker = Make(T)

The Worker module has specialized functions to spawn workers and run functions on workers.

Parameters

Signature

type t

A Worker.t type is defined with bin_io so it is possible to create functions that take a worker as an argument.

val sexp_of_t : t -> Sexplib.Sexp.t
val __bin_read_t__ : (int -> t) Core.Std.Bin_prot.Read.reader
type worker = t

A type alias to make the Connection and Managed signature more readable

type 'a functions
val functions : t functions

Accessor for the functions implemented by this worker type

type worker_state_init_arg
type connection_state_init_arg
val id : t -> Id.t
val serve : ?max_message_size:int -> ?handshake_timeout:Core.Std.Time.Span.t -> ?heartbeat_config:Async.Std.Rpc.Connection.Heartbeat_config.t -> worker_state_init_arg -> worker Async.Std.Deferred.t

serve arg will start an Rpc server in process implementing all the functions of the given worker.

module Connection : sig .. end
type 'a with_spawn_args = ?where:Executable_location.t -> ?env:(string * string) list -> ?rpc_max_message_size:int -> ?rpc_handshake_timeout:Core.Std.Time.Span.t -> ?rpc_heartbeat_config:Async.Std.Rpc.Connection.Heartbeat_config.t -> ?connection_timeout:Core.Std.Time.Span.t -> ?cd:string -> ?umask:int -> redirect_stdout:Fd_redirection.t -> redirect_stderr:Fd_redirection.t -> on_failure:(Core.Std.Error.t -> unit) -> worker_state_init_arg -> 'a

spawn init_arg ?where ?on_failure () will create a worker on where that can subsequently run some functions.

where defaults to `Local but can be specified to be some remote host.

cd defaults to / and can be used to change the current working directory of a spawned worker.

on_failure exn will be called inside Monitor.current () at the time of the call to spawn in the master when the spawned worker raises a background exception. All exceptions raised before function return will be returned to the caller.

worker_state_init_arg will be passed to Worker_state.init of the given Worker_spec module. This initializes a persistent worker state for all connections to this worker.

val spawn_and_connect : (connection_state_init_arg:connection_state_init_arg -> (t * Connection.t) Core.Std.Or_error.t Async.Std.Deferred.t) with_spawn_args
val spawn_and_connect_exn : (connection_state_init_arg:connection_state_init_arg -> (t * Connection.t) Async.Std.Deferred.t) with_spawn_args