package polling_state_rpc

  1. Overview
  2. Docs
An RPC which tracks state on the client and server so it only needs to send diffs across the wire.

Install

Dune Dependency

Authors

Maintainers

Sources

polling_state_rpc-v0.16.0.tar.gz
sha256=6b930abc3c9863d2391882d78d56694d3c4ed58f0d364e5b17f21d7d1ec10d49

doc/polling_state_rpc/Polling_state_rpc/Client/index.html

Module Polling_state_rpc.ClientSource

Sourcetype ('query, 'response) rpc := ('query, 'response) t
Sourcetype ('query, 'response) t

A Client.t is the method by which polling-state-rpcs are dispatched to the server, and their results collected by the client. Clients independently track responses and perform diff updates, so if you have two state-rpcs that share the same underlying rpc, you should make a new client for each one.

Sourceval create : ?initial_query:'query -> ('query, 'response) rpc -> ('query, 'response) t
Sourceval dispatch : ('query, 'response) t -> Async_rpc_kernel.Rpc.Connection.t -> 'query -> 'response Async_kernel.Deferred.Or_error.t

Dispatch will call the rpc and return the corresponding response. If you're listening for responses via bus, the response will also be communicated there.

Sourceval redispatch : ('query, 'response) t -> Async_rpc_kernel.Rpc.Connection.t -> 'response Async_kernel.Deferred.Or_error.t

Same as dispatch but reusing the previous query. This function throws if dispatch or set_query was not called beforehand.

Sourceval forget_on_server : ('query, 'response) t -> Async_rpc_kernel.Rpc.Connection.t -> unit Async_kernel.Deferred.Or_error.t

Asks the server to forget any state related to the specified client. Use this function on clients that might not be used again, so that the server can free up memory. If the server side of the RPC was built using implement_with_client_state then a `on_client_forgotten` function (if provided) will be called.

In addition, any queued and ongoing dispatches will get cancelled.

Calling dispatch after forget_on_server works just fine, but will require the server to send the entire response, rather than merely the diff from the previous response. In other words, clearing a client only affects speed/memory; it should have no effect on the results returned by subsequent calls to dispatch or redispatch.

Sourceval query : ('query, _) t -> 'query option

Returns the most recent query.

Sourceval bus : ('query, 'response) t -> ('query -> 'response -> unit) Bus.Read_only.t

Receives a bus which forwards all the responses that come from this client alongside the query which requested them.

OCaml

Innovation. Community. Security.