Module Main

module Main: sig .. end
Server Main Process

type json = Json.t 
type kind = [ `EXEC | `GET | `SET ] 
val string_of_kind : kind -> string
val pp_kind : Format.formatter -> kind -> unit

Request Registry


val register : kind -> string -> (json -> json) -> unit
val find : string -> (kind * (json -> json)) option
val exec : string -> json -> json

Server Main Process


type 'a request = [ `Kill of 'a | `Poll | `Request of 'a * string * json | `Shutdown ] 
Type of request messages. Parametrized by the type of request identifiers.
type 'a response = [ `Data of 'a * json
| `Error of 'a * string
| `Killed of 'a
| `Rejected of 'a ]
Type of response messages. Parametrized by the type of request identifiers.
type 'a message = {
   requests : 'a request list;
   callback : 'a response list -> unit;
}
A paired request-response message. The callback will be called exactly once for each received message.
val run : pretty:(Format.formatter -> 'a -> unit) ->
?equal:('a -> 'a -> bool) ->
fetch:(unit -> 'a message option) -> unit -> unit
Run a server with the provided low-level network primitives to actually exchange data.

The function does not return until the server is explicitely Shutdown. Logs are monitored unless ~logs:false is specified.

Default equality is the standard `(=)` one.

val yield : unit -> unit
Yield the server during the currently running request. Actually, calls !Db.progress().
val kill : unit -> 'a
Kills the currently running request. Actually raises an exception.
val on : (bool -> unit) -> unit
Register a callback to listen for server activity. All callbacks would be executed in their order of registration. They shall never raise any exception.