package babel

  1. Overview
  2. Docs
type +_ t

An a t selects a dispatch function of type a, which will typically be a function type, given a version menu supplied by the server.

In order to use this interface, the callee must provide a version menu. Use Async.Versioned_rpc.Menu.add for this.

NOTE Babel does not catch exceptions raised by caller conversion functions.

val shapes : _ t -> (Async_rpc_kernel.Rpc.Description.t * Shape.t) list

The protocols supported by the caller in order from most preferred to least preferred.

val descriptions : _ t -> Async_rpc_kernel.Rpc.Description.t list
val supported_rpcs : _ t -> Generic_rpc.t list
val print_shapes : _ t -> unit

Print the required set of protocols for each supported dispatching strategy in order from most preferred to least preferred. This is useful for demonstrating the final set of protocols in an expect test.

val of_list_decreasing_preference : 'a t list -> 'a t

of_list_decreasing_preference ts results in a caller that picks the first t in ts compatible with whatever version menu is supplied to dispatch_multi.

module Rpc : sig ... end

High level functions for working with callers in the style of Async.Rpc.Rpc.dispatch.

module Rpc_exn : sig ... end

High level functions for working with callers in the style of Async.Rpc.Rpc.dispatch_exn.

module Rpc' : sig ... end

High level functions for working with callers in the style of Async.Rpc.Rpc.dispatch'. There is no Babel.Caller.Rpc'.dispatch_multi. Use the more general Babel.Caller.to_dispatch_fun.

module Pipe_rpc : sig ... end

High level functions for working with callers in the style of Async.Rpc.Pipe_rpc.dispatch.

module Pipe_rpc_exn : sig ... end

High level functions for working with callers in the style of Async.Rpc.Pipe_rpc.dispatch_exn.

module Pipe_rpc_iter : sig ... end

High level functions for working with callers in the style of Async.Rpc.Pipe_rpc.dispatch_iter.

module State_rpc : sig ... end

High level functions for working with callers in the style of Async.Rpc.State_rpc.dispatch.

module One_way : sig ... end

High level functions for working with callers in the style of Async.Rpc.One_way.dispatch.

module One_way_exn : sig ... end

High level functions for working with callers in the style of Async.Rpc.One_way.dispatch_exn.

module One_way' : sig ... end

High level functions for working with callers in the style of Async.Rpc.One_way.dispatch'. There is no Babel.Caller.One_way'.dispatch_multi. Use the more general Babel.Caller.to_dispatch_fun.

module Streamable_plain_rpc : sig ... end

High level functions for working with callers in the style of Streamable.Plain_rpc.dispatch.

module Streamable_pipe_rpc : sig ... end

High level functions for working with callers in the style of Streamable.Pipe_rpc.dispatch.

module Streamable_state_rpc : sig ... end

High level functions for working with callers in the style of Streamable.State_rpc.dispatch.

Produce a dispatch function that is compatible with the given version menu. You should prefer to dispatch using the more specialized functions above. You would use this function if you want to precompute the version menu checks or if you have changed the type to something incompatible with the more specialized functions for particular types of Rpc protocols.

Given a version menu, returns the description of the RPC that will be called by the dispatch function.

val map : 'a t -> f:('a -> 'b) -> 'b t

Transform the dispatch function generated by a caller. Since in practice we are usually working with functions, it may be enlightening to think of the type as:

val map
  :  ('a1 -> 'b1) t
  -> f:(('a1 -> 'b1) -> 'a2 -> 'b2)
  -> ('a2 -> 'b2) t

Most of the time you should use the higher-level map_query and map_response functions instead of map. map is intended to be used for more radical changes to an implementation, such as to change the type of rpc protocol.

to_dispatch_fun (map t ~f) menu = Or_error.map (to_dispatch_fun t menu) ~f
val map_query : ('a -> 'b) t -> f:('c -> 'a) -> ('c -> 'b) t

A specialization of map for the query type of a protocol.

In practice, most implementations will return deferreds or other complex types, so you should prefer to use more specialized functions, such as Rpc.map_query.

val map_response : ('a -> 'b) t -> f:('b -> 'c) -> ('a -> 'c) t

A specialization of map for the response type of a protocol.

In practice, most implementations will return deferreds or other complex types, so you should prefer to use more specialized functions, such as Rpc.map_response.

Return whether any of strategies in the rpc protocol menu are supported by the dispatch function.

OCaml

Innovation. Community. Security.