Module Rpc.Pipe_rpc
module Id : sig ... endmodule Metadata : sig ... endval create : ?client_pushes_back:unit -> name:string -> version:int -> bin_query:'query Bin_prot.Type_class.t -> bin_response:'response Bin_prot.Type_class.t -> bin_error:'error Bin_prot.Type_class.t -> unit -> ('query, 'response, 'error) tval bin_query : ('query, _, _) t -> 'query Bin_prot.Type_class.tval bin_response : (_, 'response, _) t -> 'response Bin_prot.Type_class.tval bin_error : (_, _, 'error) t -> 'error Bin_prot.Type_class.tval implement : ('query, 'response, 'error) t -> ('connection_state -> 'query -> ('response Async_kernel.Pipe.Reader.t, 'error) Core_kernel.Result.t Async_kernel.Deferred.t) -> 'connection_state Async_rpc_kernel__Rpc.Implementation.tThe pipe returned by the implementation function will be closed automatically when either the connection to the client is closed or the client closes their pipe.
module Direct_stream_writer : sig ... endA
Direct_stream_writer.tis a simple object for responding to aPipe_rpcquery.
val implement_direct : ('query, 'response, 'error) t -> ('connection_state -> 'query -> 'response Direct_stream_writer.t -> (unit, 'error) Core_kernel.Result.t Async_kernel.Deferred.t) -> 'connection_state Async_rpc_kernel__Rpc.Implementation.tSimilar to
implement, but you are given the writer instead of providing a writer and the writer is aDirect_stream_writer.tinstead of aPipe.Writer.t.The main advantage of this interface is that it consumes far less memory per open query.
Though the implementation function is given a writer immediately, the result of the client's call to
dispatchwill not be determined until after the implementation function returns. Elements written before the function returns will be queued up to be written after the function returns.
val dispatch : ('query, 'response, 'error) t -> Async_rpc_kernel__Rpc.Connection.t -> 'query -> ('response Async_kernel.Pipe.Reader.t * Metadata.t, 'error) Core_kernel.Result.t Core_kernel.Or_error.t Async_kernel.Deferred.tThis has
(..., 'error) Result.tas its return type to represent the possibility of the call itself being somehow erroneous (but understood - the outerOr_error.tencompasses failures of that nature). Note that this cannot be done simply by making'responsea result type, since('response Pipe.Reader.t, 'error) Result.tis distinct from('response, 'error) Result.t Pipe.Reader.t.Closing the pipe has the effect of calling
abort.
val dispatch_exn : ('query, 'response, 'error) t -> Async_rpc_kernel__Rpc.Connection.t -> 'query -> ('response Async_kernel.Pipe.Reader.t * Metadata.t) Async_kernel.Deferred.t
module Pipe_message : sig ... endThe input type of the
fpassed todispatch_iter.
module Pipe_response : sig ... endThe output type of the
fpassed todispatch_iter. This is analagous to a simpleunit Deferred.t, withContinuebeing likeDeferred.unit, but it is made explicit when no waiting should occur.
val dispatch_iter : ('query, 'response, 'error) t -> Async_rpc_kernel__Rpc.Connection.t -> 'query -> f:('response Pipe_message.t -> Pipe_response.t) -> (Id.t, 'error) Core_kernel.Result.t Core_kernel.Or_error.t Async_kernel.Deferred.tCalling
dispatch_iter t conn query ~fis similar to callingdispatch t conn queryand then iterating over the result pipe withf. The main advantage it offers is that its memory usage is much lower, making it more suitable for situations where many queries are open at once.fmay be fed any number ofUpdate _messages, followed by a singleClosed _message.fcan cause the connection to stop reading messages off of its underlyingReader.tby returningWait _. This is the same as what happens when a client stops reading from the pipe returned bydispatchwhen thePipe_rpc.thasclient_pushes_backset.When successful,
dispatch_iterreturns anId.tafter the subscription is started. This may be fed toabortwith the samePipe_rpc.tandConnection.tas the call todispatch_iterto cancel the subscription, which will close the pipe on the implementation side. Calling it with a differentPipe_rpc.torConnection.thas undefined behavior.
val abort : (_, _, _) t -> Async_rpc_kernel__Rpc.Connection.t -> Id.t -> unitabort rpc connection idgiven an RPC and the id returned as part of a call to dispatch, abort requests that the other side of the connection stop sending updates.If you are using
dispatchrather thandispatch_iter, you are encouraged to close the pipe you receive rather than callingabort-- both of these have the same effect.
val close_reason : Metadata.t -> Async_rpc_kernel__Rpc.Pipe_close_reason.t Async_kernel.Deferred.tclose_reason metadatawill be determined sometime after the pipe associated withmetadatais closed. Its value will indicate what caused the pipe to be closed.
val client_pushes_back : (_, _, _) t -> boolval name : (_, _, _) t -> stringval version : (_, _, _) t -> intval description : (_, _, _) t -> Async_rpc_kernel__Rpc.Description.t