package babel

  1. Overview
  2. Docs

Like Rpc.Pipe_rpc.Direct_stream_writer.Group, but with the ability to maintain multiple subgroups. One Rpc.Pipe_rpc.Direct_stream_writer.Group is maintained per implemented RPC, so values are only converted and serialized once per RPC.

Since values are only converted once, the functions passed to Babel.Callee.Pipe_rpc_direct.{filter_,}map_response must be pure, or unexpected results can occur. To determine whether two direct stream writers can be combined, Direct_stream_writer.t contains a type id for the output type, and a unique Transformation_id that is intended to uniquely identify the conversion function from the input type to the output type.

Because the library has no way of automatically identifying whether two 'a Direct_stream_writer.t's with output type 'b have the same conversion function 'a -> 'b option, users must promise that the Transformation_id.t is never re-used with a different function. To take advantage of the grouping, the Expert functions above must be used to create the writer. Using the non expert writers will result in a direct stream writer which cannot be combined and will be put in its own group. Babel.Callee.Pipe_rpc_direct.{filter_,}map_response use the Expert functions so they can be combined.

type 'a writer := 'a t
type 'a t
val create : store_last_value_and_send_on_add:bool -> _ t
val add_exn : 'a t -> 'a writer -> unit

Add a direct stream writer to the group. Raises if Rpc.Pipe_rpc.Direct_stream_writer.Group.add_exn would raise. If ~store_last_value_and_send_on_add:true was passed when creating the group, add_exn will additionally write the stored last value to the writer. This will only involve conversion and serialization if the new writer uses a different protocol than the other writers in the group.

val write : 'a t -> 'a -> unit Async_kernel.Deferred.t

Write a message to all direct writers in the group and then waits for flushed.

val write_without_pushback : 'a t -> 'a -> unit

Write a message to all direct writers in the group without waiting for flushed.

val length : _ t -> int

Number of elements in the group

module For_testing : sig ... end
OCaml

Innovation. Community. Security.