package capnp-rpc-lwt

  1. Overview
  2. Docs

Module Capnp_rpc_lwt.ServiceSource

Functions for service implementors.

Sourcetype ('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.

Sourcemodule Response : sig ... end
Sourceval return : 'a Response.t -> 'a StructRef.t

return r wraps up a simple local result as a promise.

Sourceval return_empty : unit -> 'a StructRef.t

return_empty () is a promise for a response with no payload.

Sourceval 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.

Sourceval fail : ?ty:Capnp_rpc.Exception.ty -> ('a, Format.formatter, unit, 'b StructRef.t) format4 -> 'a

fail msg is an exception with reason msg.

Sourceval fail_lwt : ?ty:Capnp_rpc.Exception.ty -> ('a, Format.formatter, unit, (_, [> `Capnp of Capnp_rpc.Error.t ]) Lwt_result.t) format4 -> 'a

fail_lwt msg is like fail msg, but can be used with return_lwt.