Up

Module type Creator

Signature

type worker
val bin_read_worker : worker Core.Std.Bin_prot.Read.reader
val __bin_read_worker__ : (int -> worker) Core.Std.Bin_prot.Read.reader
val bin_size_worker : worker Core.Std.Bin_prot.Size.sizer
val bin_write_worker : worker Core.Std.Bin_prot.Write.writer
type state
val create_rpc : ?name:string -> f:(state -> 'query -> 'response Async.Std.Deferred.t) -> bin_input:'query Core.Std.Bin_prot.Type_class.t -> bin_output:'response Core.Std.Bin_prot.Type_class.t -> unit -> (worker, 'query, 'response) Function.t

create_rpc ?name ~f ~bin_input ~bin_output () will create an Rpc.Rpc.t with name if specified and use f as an implementation for this Rpc. It returns back a Function.t, a type-safe Rpc.Rpc.t.

val create_pipe : ?name:string -> f:(state -> 'query -> 'response Async.Std.Pipe.Reader.t Async.Std.Deferred.t) -> bin_input:'query Core.Std.Bin_prot.Type_class.t -> bin_output:'response Core.Std.Bin_prot.Type_class.t -> unit -> (worker, 'query, 'response Async.Std.Pipe.Reader.t) Function.t

create_pipe ?name ~f ~bin_input ~bin_output () will create an Rpc.Pipe_rpc.t with name if specified. The implementation for this Rpc is a function that creates a Pipe.Reader.t and a Pipe.Writer.t, then calls f arg ~writer and returns the reader. create_pipe returns a Function_piped.t which is a type-safe Rpc.Pipe_rpc.t.

val of_async_rpc : f:(state -> 'query -> 'response Async.Std.Deferred.t) -> ('query, 'response) Async.Std.Rpc.Rpc.t -> (worker, 'query, 'response) Function.t

of_async_rpc ~f rpc is the analog to create_rpc but instead of creating an Rpc protocol, it uses the supplied one

val of_async_pipe_rpc : f:(state -> 'query -> 'response Async.Std.Pipe.Reader.t Async.Std.Deferred.t) -> ('query, 'response, Core.Std.Error.t) Async.Std.Rpc.Pipe_rpc.t -> (worker, 'query, 'response Async.Std.Pipe.Reader.t) Function.t

of_async_pipe_rpc ~f rpc is the analog to create_pipe but instead of creating a Pipe_rpc protocol, it uses the supplied one

val run : worker -> f:(worker, 'query, 'response) Function.t -> arg:'query -> 'response Core.Std.Or_error.t Async.Std.Deferred.t

run is exposed in this interface so the implementations of functions can include running other functions defined on this worker. A function can take a worker as an argument and call run on this worker

val run_exn : worker -> f:(worker, 'query, 'response) Function.t -> arg:'query -> 'response Async.Std.Deferred.t