Module Parallel.Make
module Worker = Make(T)
The Worker module has specialized functions to spawn workers and run functions on workers.
Parameters
S : Worker_spec
Signature
type ('worker, 'query, 'response) _functiontype tA
Worker.ttype is definedwith bin_ioso it is possible to create functions that take a worker as an argument.
include Bin_prot.Binable.S with type t := t
include Bin_prot.Binable.S_only_functions with type t := t
val bin_size_t : t Bin_prot.Size.sizerval bin_write_t : t Bin_prot.Write.writerval bin_read_t : t Bin_prot.Read.readerval __bin_read_t__ : (int -> t) Bin_prot.Read.readerThis function only needs implementation if
texposed to be a polymorphic variant. Despite what the type reads, this does *not* produce a function after reading; instead it takes the constructor tag (int) before reading and reads the rest of the varianttafterwards.
val bin_shape_t : Bin_prot.Shape.tval bin_writer_t : t Bin_prot.Type_class.writerval bin_reader_t : t Bin_prot.Type_class.readerval bin_t : t Bin_prot.Type_class.t
val sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.t
type worker= tA type alias to make the
Connectionsignature more readable
module Id : Core.Identifiableval id : t -> Id.tval serve : ?max_message_size:int -> ?handshake_timeout:Core.Time.Span.t -> ?heartbeat_config:Async.Rpc.Connection.Heartbeat_config.t -> worker_state_init_arg -> worker Async.Deferred.tserve argwill start an Rpc server in process implementing all the functions of the given worker.
module Connection : sig ... endmodule Shutdown_on : functor (M : Core.T1) -> sig ... endtype 'a with_spawn_args= ?where:Rpc_parallel.Executable_location.t -> ?name:string -> ?env:(string * string) list -> ?connection_timeout:Core.Time.Span.t -> ?cd:string -> on_failure:(Core.Error.t -> unit) -> 'aThe various
spawnfunctions create a new worker process that implements the functions specified in theWorker_spec.namewill be attached to certain error messages and is useful for debugging.envextends the environment of the spawned worker process.connection_timeoutis used for various internal timeouts. This may need be to increased if the init arg is really large (serialization and deserialization takes more thanconnection_timeout).cdchanges the current working directory of a spawned worker process.shutdown_onspecifies when a worker should shut itself down.on_failure exnwill be called in the spawning process upon the worker process raising a background exception. All exceptions raised before functions return will be returned to the caller.on_failurewill be called inMonitor.current ()at the time of this spawn call. The worker initiates shutdown upon sending the exception to the master process.worker_state_init_arg(below) will be passed toinit_worker_stateof the givenWorker_specmodule. This initializes a persistent worker state for all connections to this worker.
val spawn : (?umask:int -> shutdown_on:'a Shutdown_on(Core.Or_error).t -> redirect_stdout:Rpc_parallel.Fd_redirection.t -> redirect_stderr:Rpc_parallel.Fd_redirection.t -> worker_state_init_arg -> 'a) with_spawn_argsThe spawned worker process daemonizes. Any initialization errors that wrote to stderr (Rpc_parallel internal initialization, not user initialization code) will be captured and rewritten to the spawning process's stderr with the prefix "
WORKER %NAME% STDERR".redirect_stdoutandredirect_stderrspecify stdout and stderr of the worker process.
val spawn_exn : (?umask:int -> shutdown_on:'a Shutdown_on(Core.Monad.Ident).t -> redirect_stdout:Rpc_parallel.Fd_redirection.t -> redirect_stderr:Rpc_parallel.Fd_redirection.t -> worker_state_init_arg -> 'a) with_spawn_args
module Spawn_in_foreground_result : sig ... endval spawn_in_foreground : (shutdown_on:'a Shutdown_on(Spawn_in_foreground_result).t -> worker_state_init_arg -> 'a) with_spawn_argsSimilar to
spawnbut the worker process does not daemonize. If the process was spawned on a remote host, the sshProcess.tis returned.Remember to call
Process.waiton the returnedProcess.tto avoid zombie processes.
module Spawn_in_foreground_exn_result : sig ... endval spawn_in_foreground_exn : (shutdown_on:'a Shutdown_on(Spawn_in_foreground_exn_result).t -> worker_state_init_arg -> 'a) with_spawn_argsval shutdown : t -> unit Core.Or_error.t Async.Deferred.tshutdownattempts to connect to a worker. Upon success,Shutdown.shutdown 0is run in the worker. If you want strong guarantees that a worker did shutdown, consider usingspawn_in_foregroundand inspecting theProcess.t.
module Deprecated : sig ... endmodule For_internal_testing : sig ... endThis module is used for internal testing of the rpc_parallel library.