package polling_state_rpc

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type ('query, 'response) rpc := ('query, 'response) t
type ('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.

val create : ?initial_query:'query -> ('query, 'response) rpc -> ('query, 'response) t
val 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.

val 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 returns an Error if the query was not set with dispatch or create ~initial_query beforehand.

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

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

Returns the most recent query.

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