Babel.CalleeSourceAn a t can be used to define many rpc implementations in one go, based on a single model implementation supplied to implement_multi. The type a is usually going to be a function from the query type to the response type, including whatever deferreds, pipes, etc. that the implementation will be responsible for.
val implement_multi :
?on_exception:Async_rpc_kernel.Rpc.On_exception.t ->
'a t ->
f:('s -> Async_rpc_kernel.Rpc.Description.t -> 'a) ->
's Async_rpc_kernel.Rpc.Implementation.t list Core.Or_error.tFrom a model implementation, define some number of rpc implementations. In practice, the result of the supplied function is usually a function, so it may be enlightening to think of the type as:
val implement_multi
: ?on_exception:Rpc.On_exception.t
-> ('a -> 'b) t
-> f:('s -> Rpc.Description.t -> 'a -> 'b)
-> 's Rpc.Implementation.t list Or_error.tReturns an error if any rpcs are duplicated.
val implement_multi_exn :
?on_exception:Async_rpc_kernel.Rpc.On_exception.t ->
'a t ->
f:('s -> Async_rpc_kernel.Rpc.Description.t -> 'a) ->
's Async_rpc_kernel.Rpc.Implementation.t listThe protocols supported by the callee. Returns an error if any rpcs are duplicated.
Print a description of every supported protocol. This is useful for demonstrating the final set of protocols in an expect test.
of_list ts results in a callee that implements everything that each element of ts implements.
implement_multi (of_list ts) ~f = List.concat_map ts ~f:(implement_multi ~f)High level functions for working with callees in the style of Async.Rpc.Rpc.implement.
High level functions for working with callees in the style of Async.Rpc.Rpc.implement'.
High level functions for working with callees in the style of Async.Rpc.Pipe_rpc.implement.
High level functions for working with callees in the style of Async.Rpc.Pipe_rpc.implement_direct.
High level functions for working with callees in the style of Async.Rpc.State_rpc.implement.
High level functions for working with callees in the style of Async.Rpc.One_way.implement.
High level functions for working with callees in the style of Streamable.Plain_rpc.implement.
High level functions for working with callees in the style of Streamable.Pipe_rpc.implement.
High level functions for working with callees in the style of Streamable.State_rpc.implement.
map t ~f transforms the model function supplied to implement_multi. 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:(('a2 -> 'b2) -> 'a1 -> 'b1)
-> ('a2 -> 'b2) tMost of the time, you probably would prefer to use more specialized functions, such as Rpc.map_query and Rpc.map_response, instead of map.
implement_multi (map t ~f) ~f:g = implement_multi t ~f:(Fn.compose f g)map_query is a specialization of map for the query type of a callee.
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.
implement_multi (map_query t ~f) ~f:g
= implement_multi t ~f:(fun s query -> g s (f query))map_response is a specialization of map for the return type of an implementation.
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. map_response is intended to be used for more radical changes to an implementation, such as to change the type of rpc protocol.
implement_multi (map_response t ~f) ~f:g
= implement_multi t ~f:(fun s query -> f (g s query))