Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
Functions for service implementors.
type ('a, 'b) method_t = 'a -> (unit -> unit) -> 'b StructRef.t
An ('a, 'b) method_t is a method implementation that takes a reader for the parameters and a function to release the capabilities in the parameters, and returns a promise for the results.
module Response : sig ... end
val return : 'a Response.t -> 'a StructRef.t
return r
wraps up a simple local result as a promise.
val return_empty : unit -> 'a StructRef.t
return_empty ()
is a promise for a response with no payload.
val return_lwt :
(unit -> ('a Response.t, [< `Capnp of Capnp_rpc.Error.t ]) Lwt_result.t) ->
'a StructRef.t
return_lwt fn
is a local promise for the result of Lwt thread fn ()
. If fn ()
fails, the error is logged and an "Internal error" returned to the caller. If it returns an Error
value then that error is returned to the caller. Note that this does not support pipelining (any messages sent to the response will be queued locally until it fn
has produced a result), so it may be better to return immediately a result containing a promise in some cases.
val fail :
?ty:Capnp_rpc.Exception.ty ->
('a, Stdlib.Format.formatter, unit, 'b StructRef.t) Stdlib.format4 ->
'a
fail msg
is an exception with reason msg
.