package rpc_parallel

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

If you want more direct control over your executable, you can use the Expert module instead of start_app. If you use Expert, you are responsible for starting the master and worker rpc servers. worker_command_args will be the arguments sent to each spawned worker. Running your executable with these args must follow a code path that calls worker_init_before_async_exn and then start_worker_server_exn. An easy way to do this is to use worker_command.

val start_master_server_exn : ?rpc_max_message_size:int -> ?rpc_handshake_timeout:Core.Time.Span.t -> ?rpc_heartbeat_config:Async.Rpc.Connection.Heartbeat_config.t -> ?pass_name:bool -> Backend_and_settings.t -> worker_command_args:string list -> unit -> unit

start_master_server_exn must be called in the single master process. It is necessary to be able to spawn workers. Raises if the process was spawned.

If pass_name is false, the ?name argument to spawned workers will not be propagated into the worker's command line. This override is only needed to support the "deprecated option" for implementing worker commands described below.

You have two options for implementing the worker process, a simple one and a deprecated one.

Simple option: just make sure worker_command is somewhere in the command hierarchy of the same executable in which start_master_server_exn is called, with a subcommand path equal to worker_command_args. It is possible for multiple calls to start_master_server_exn to share the same worker_command_args.

Deprecated option: implement something at least as complicated yourself using worker_init_before_async_exn and start_worker_server_exn. This option may go away in the future.

val worker_command : (module Backend) -> Async.Command.t
module Worker_env : sig ... end
val worker_init_before_async_exn : unit -> Worker_env.t

worker_init_before_async_exn must be called in a spawned worker process before the async scheduler has started. You must not read from stdin before this function call.

This has the side effect of calling chdir.

val start_worker_server_exn : (module Backend) -> Worker_env.t -> unit

start_worker_server_exn must be called in each spawned process. It is illegal to call both start_master_server_exn and start_worker_server_exn in the same process. Raises if the process was not spawned.

This has the side effect of scheduling a job that completes the daemonization of this process (if the process should daemonize). This includes redirecting stdout and stderr according to redirect_stdout and redirect_stderr. All writes to stdout before this job runs are blackholed. All writes to stderr before this job runs are redirected to the spawning process's stderr.

OCaml

Innovation. Community. Security.