Module Rpc.Expert
module Responder : sig ... end
val schedule_dispatch : Connection.t -> rpc_tag:string -> version:int -> Core_kernel.Bigstring.t -> pos:int -> len:int -> handle_response:(Core_kernel.Bigstring.t -> pos:int -> len:int -> unit Async_kernel.Deferred.t) -> handle_error:(Core_kernel.Error.t -> unit) -> [ `Flushed of unit Async_kernel.Deferred.t | `Connection_closed ]
This just schedules a write, so the
Bigstring.t
should not be overwritten until the flushedDeferred.t
is determined.The return value of
handle_response
has the same meaning as in the function argument ofImplementations.Expert.create
.
val dispatch : Connection.t -> rpc_tag:string -> version:int -> Core_kernel.Bigstring.t -> pos:int -> len:int -> handle_response:(Core_kernel.Bigstring.t -> pos:int -> len:int -> unit Async_kernel.Deferred.t) -> handle_error:(Core_kernel.Error.t -> unit) -> [ `Ok | `Connection_closed ]
type implementation_result
=
|
Replied
|
Delayed_response of unit Async_kernel.Deferred.t
Result of callbacks passed to
implement
andimplement'
andimplement_for_tag_and_version
andimplement_for_tag_and_version'
:Replied
means that the response has already been sent using one of the functions ofResponder
Delayed_response d
means that the implementation is done using the input bigstring, but hasn't send the response yet. Whend
becomes determined it is expected that the response has been sent.
Note: it is NOT OK for an implementation to return:
Delayed_response (Responder.schedule responder buf ~pos:... ~len:...)
where
buf
is the same bigstring as the one containing the query. This is because it would indicate thatbuf
can be overwritten even though it is still being used byResponder.schedule
.
val implement : (_, _) t -> ('connection_state -> Responder.t -> Core_kernel.Bigstring.t -> pos:int -> len:int -> implementation_result Async_kernel.Deferred.t) -> 'connection_state Implementation.t
val implement' : (_, _) t -> ('connection_state -> Responder.t -> Core_kernel.Bigstring.t -> pos:int -> len:int -> implementation_result) -> 'connection_state Implementation.t
val implement_for_tag_and_version : rpc_tag:string -> version:int -> ('connection_state -> Responder.t -> Core_kernel.Bigstring.t -> pos:int -> len:int -> implementation_result Async_kernel.Deferred.t) -> 'connection_state Implementation.t
val implement_for_tag_and_version' : rpc_tag:string -> version:int -> ('connection_state -> Responder.t -> Core_kernel.Bigstring.t -> pos:int -> len:int -> implementation_result) -> 'connection_state Implementation.t