package rpc_parallel

  1. Overview
  2. Docs
Type-safe parallel library built on top of Async_rpc

Install

Dune Dependency

Authors

Maintainers

Sources

rpc_parallel-v0.11.0.tar.gz
sha256=03c19c40fa97f990312b139aea2954a691271aa0717d2a6b2490d6d91be80290
md5=d3280f264eed61c5bc3e92e6841743b6

Description

Rpc_parallel offers an API to define various workers and protocols, spawn workers as separate processes, and communicate with them using Async Rpc.

Published: 22 Mar 2018

README

README.org

# Mental Model

- =Worker.t= identifies a worker rpc server
- =spawn= (=serve=) starts a worker Rpc server in another process (the same
  process)
- =client= connects to a worker Rpc server
- =run= dispatches on a connection to a worker Rpc server

# Top-level

It is highly recommended for =Rpc\_parallel.start\_app= and =Rpc\_parallel.Make=
calls to be top-level. But the real requirements are:

1) The master's state is initialized before any calls to =spawn=. This will be
   achieved either by =Rpc\_parallel.start\_app= or
   =Rpc\_parallel.Expert.start\_master\_server\_exn=.

2) Spawned workers (runs of your executable with a certain environment variable
   set) must start running as a worker. This will be achieved either by
   =Rpc\_parallel.start\_app= or =Rpc\_parallel.Expert.worker\_command=.

3) Spawned workers must be able to find their function implementations when they
   start running as a worker. These implementations are gathered on the
   application of the =Rpc\_parallel.Make= functor.

4) The worker implementations must be defined completely and in the same order,
   regardless of master and worker code paths. This is necessary for the masters
   and workers to agree on certain generated ids.

# Monitoring your workers

Uncaught exceptions in workers will always result in the worker shutting down.
The master can be notified of these exceptions in multiple ways:

- If the exception occured in a function implementation =f= before =f= is
  determined, the exception will be returned back to the caller. E.g. the caller
  of =spawn= or =run= will get an =Error.t= describing the exception.

- If the exception occured after =f= is determined, =on\_failure exn= will be
  called (in =Monitor.current ()= at the time of =spawn=) in the spawning
  process.

- If =redirect\_stderr= specifies a file, the worker will also write its
  exception to that file before shutting down.

# Optional Rpc Settings

The master's Rpc server will be started with the =max\_message\_size=,
=heartbeat\_config=, and =handshake\_timeout= settings passed in to
=start\_app=/=init\_master\_exn=.

Each worker's Rpc server will be started with the settings passed in upon
=spawn= or =serve= of that worker.

All =client= calls will use the corresponding Rpc settings for the given
worker/master that it is connecting to.

Dependencies (7)

  1. ocaml-migrate-parsetree >= "1.0" & < "2.0.0"
  2. jbuilder >= "1.0+beta18.1"
  3. sexplib >= "v0.11" & < "v0.12"
  4. ppx_jane >= "v0.11" & < "v0.12"
  5. core >= "v0.11" & < "v0.12"
  6. async >= "v0.11" & < "v0.12"
  7. ocaml >= "4.04.1"

Dev Dependencies

None

Used by

None

Conflicts (1)

  1. jbuilder = "1.0+beta19"
OCaml

Innovation. Community. Security.