Up

Module Function

A ('worker, 'query, 'response) Function.t is a type-safe function 'query -> 'response Deferred.t that can only be run on a 'worker. Under the hood it represents an Async Rpc protocol that we know a 'worker will implement.

Signature

type ('worker, 'query, 'response) t

Common functions that are implemented by all workers

val shutdown : (_, unit, unit) t

This implementation simply calls Shutdown.shutdown 0

This implementation will add another Log.Output for Log.Global that transfers log messages to the returned pipe. You can subscribe to a worker's log more than once and from different processes, as each call simply adds a new Log.Output. Closing the pipe will remove the corresponding Log.Output.

NOTE: You will never get any log messages before this implementation has run (there is no queuing of log messages). As a consequence, you will never get any log messages written in a worker's init functions.

val close_server : (_, unit, unit) t

A given process can have multiple worker servers running (of the same or different worker types). This implementation closes the server on which it is run. All existing open connections will remain open, but no further connections to this worker server will be accepted.

NOTE: calling close_server on a worker process that is only running one worker server will leave a stranded worker process if no other cleanup has been setup (e.g. setting up on_client_disconnect or Connection.close_finished handlers)