sig
module Implementation :
sig
type 'connection_state t
module Description :
sig
type t = { name : string; version : int; }
val t_of_sexp : Sexplib.Sexp.t -> Rpc.Implementation.Description.t
val sexp_of_t : Rpc.Implementation.Description.t -> Sexplib.Sexp.t
end
val description :
'a Rpc.Implementation.t -> Rpc.Implementation.Description.t
val lift :
'a Rpc.Implementation.t -> f:('b -> 'a) -> 'b Rpc.Implementation.t
end
module Implementations :
sig
type 'connection_state t
val null : unit -> 'connection_state Rpc.Implementations.t
val create :
implementations:'connection_state Rpc.Implementation.t list ->
on_unknown_rpc:[ `Call of rpc_tag:string -> version:int -> unit
| `Ignore
| `Raise ] ->
('connection_state Rpc.Implementations.t,
[ `Duplicate_implementations of
Rpc.Implementation.Description.t list ])
Core.Std.Result.t
val create_exn :
implementations:'connection_state Rpc.Implementation.t list ->
on_unknown_rpc:[ `Call of rpc_tag:string -> version:int -> unit
| `Ignore
| `Raise ] ->
'connection_state Rpc.Implementations.t
end
module type Connection =
sig
type t
val create :
?implementations:'s Implementations.t ->
connection_state:'s ->
?max_message_size:int ->
Import.Reader.t ->
Import.Writer.t ->
(t, Core.Std.Exn.t) Core.Std.Result.t Import.Deferred.t
val close : t -> unit Import.Deferred.t
val close_finished : t -> unit Import.Deferred.t
val is_closed : t -> bool
val bytes_to_write : t -> int
val with_close :
?implementations:'s Implementations.t ->
connection_state:'s ->
Import.Reader.t ->
Import.Writer.t ->
dispatch_queries:(t -> 'a Import.Deferred.t) ->
on_handshake_error:[ `Call of Core.Std.Exn.t -> 'a Import.Deferred.t
| `Raise ] ->
'a Import.Deferred.t
val server_with_close :
Import.Reader.t ->
Import.Writer.t ->
implementations:'s Implementations.t ->
connection_state:'s ->
on_handshake_error:[ `Call of
Core.Std.Exn.t -> unit Import.Deferred.t
| `Ignore
| `Raise ] ->
unit Import.Deferred.t
val serve :
implementations:'s Implementations.t ->
initial_connection_state:(([< Import.Socket.Address.t ] as 'a) -> 's) ->
where_to_listen:('a, 'listening_on) Tcp.Where_to_listen.t ->
?auth:('a -> bool) ->
?on_handshake_error:[ `Call of Core.Std.Exn.t -> unit
| `Ignore
| `Raise ] ->
unit -> ('a, 'listening_on) Tcp.Server.t Import.Deferred.t
module Client_implementations :
sig
type 's t = {
connection_state : 's;
implementations : 's Implementations.t;
}
val null : unit -> unit t
end
val client :
host:string ->
port:int ->
?implementations:'a Client_implementations.t ->
unit -> (t, Core.Std.Exn.t) Core.Std.Result.t Import.Deferred.t
val with_client :
host:string ->
port:int ->
?implementations:'b Client_implementations.t ->
(t -> 'a Import.Deferred.t) ->
('a, Core.Std.Exn.t) Core.Std.Result.t Import.Deferred.t
end
module Connection : Connection
module Rpc :
sig
type ('query, 'response) t
val create :
name:string ->
version:int ->
bin_query:'query Core.Std.Bin_prot.Type_class.t ->
bin_response:'response Core.Std.Bin_prot.Type_class.t ->
('query, 'response) Rpc.Rpc.t
val name : ('a, 'b) Rpc.Rpc.t -> string
val version : ('a, 'b) Rpc.Rpc.t -> int
val implement :
('query, 'response) Rpc.Rpc.t ->
('connection_state -> 'query -> 'response Import.Deferred.t) ->
'connection_state Rpc.Implementation.t
val dispatch :
('query, 'response) Rpc.Rpc.t ->
Rpc.Connection.t ->
'query -> 'response Core.Std.Or_error.t Import.Deferred.t
val dispatch_exn :
('query, 'response) Rpc.Rpc.t ->
Rpc.Connection.t -> 'query -> 'response Import.Deferred.t
end
module Pipe_rpc :
sig
type ('query, 'response, 'error) t
module Id : sig type t end
val create :
name:string ->
version:int ->
bin_query:'query Core.Std.Bin_prot.Type_class.t ->
bin_response:'response Core.Std.Bin_prot.Type_class.t ->
bin_error:'error Core.Std.Bin_prot.Type_class.t ->
('query, 'response, 'error) Rpc.Pipe_rpc.t
val implement :
('query, 'response, 'error) Rpc.Pipe_rpc.t ->
('connection_state ->
'query ->
aborted:unit Import.Deferred.t ->
('response Import.Pipe.Reader.t, 'error) Core.Std.Result.t
Import.Deferred.t) ->
'connection_state Rpc.Implementation.t
val dispatch :
('query, 'response, 'error) Rpc.Pipe_rpc.t ->
Rpc.Connection.t ->
'query ->
('response Import.Pipe.Reader.t * Rpc.Pipe_rpc.Id.t, 'error)
Core.Std.Result.t Core.Std.Or_error.t Import.Deferred.t
val dispatch_exn :
('query, 'response, 'error) Rpc.Pipe_rpc.t ->
Rpc.Connection.t ->
'query ->
('response Import.Pipe.Reader.t * Rpc.Pipe_rpc.Id.t)
Import.Deferred.t
val abort :
('a, 'b, 'c) Rpc.Pipe_rpc.t ->
Rpc.Connection.t -> Rpc.Pipe_rpc.Id.t -> unit
val name : ('a, 'b, 'c) Rpc.Pipe_rpc.t -> string
val version : ('a, 'b, 'c) Rpc.Pipe_rpc.t -> int
end
module State_rpc :
sig
type ('query, 'state, 'update, 'error) t
module Id : sig type t end
val create :
name:string ->
version:int ->
bin_query:'query Core.Std.Bin_prot.Type_class.t ->
bin_state:'state Core.Std.Bin_prot.Type_class.t ->
bin_update:'update Core.Std.Bin_prot.Type_class.t ->
bin_error:'error Core.Std.Bin_prot.Type_class.t ->
('query, 'state, 'update, 'error) Rpc.State_rpc.t
val implement :
('query, 'state, 'update, 'error) Rpc.State_rpc.t ->
('connection_state ->
'query ->
aborted:unit Import.Deferred.t ->
('state * 'update Import.Pipe.Reader.t, 'error) Core.Std.Result.t
Import.Deferred.t) ->
'connection_state Rpc.Implementation.t
val dispatch :
('query, 'state, 'update, 'error) Rpc.State_rpc.t ->
Rpc.Connection.t ->
'query ->
update:('state -> 'update -> 'state) ->
('state * ('state * 'update) Import.Pipe.Reader.t *
Rpc.State_rpc.Id.t, 'error)
Core.Std.Result.t Core.Std.Or_error.t Import.Deferred.t
val abort :
('a, 'b, 'c, 'd) Rpc.State_rpc.t ->
Rpc.Connection.t -> Rpc.State_rpc.Id.t -> unit
val name : ('a, 'b, 'c, 'd) Rpc.State_rpc.t -> string
val version : ('a, 'b, 'c, 'd) Rpc.State_rpc.t -> int
end
end