Up

Module Versioned : S with type conn = Async_extra.Import.Versioned_rpc.Connection_with_menu.t and type address = Core.Std.Host_and_port.t

Signature

type t
type address = Core.Std.Host_and_port.t
module Event : sig .. end
val create : server_name:string -> ?log:Async_extra.Import.Log.t -> ?on_event:(Event.t -> unit) -> connect:(address -> conn Core.Std.Or_error.t Async_extra.Import.Deferred.t) -> (unit -> address Core.Std.Or_error.t Async_extra.Import.Deferred.t) -> t

create ~server_name ~log get_address returns a persistent rpc connection to a server whose host and port are obtained via get_address every time we try to connect. For example, get_address might look up a server's host and port in catalog at a particular path to which multiple redundant copies of a service are publishing their location. If one copy dies, we get the address of the another one when looking up the address afterwards.

All connection events (see the type above) are passed to the on_event callback, if given. If a ~log is supplied then these events will be written there as well, with a "persistent-connection-to" tag value of server_name, which should be the name of the server we are connecting to.

`Failed_to_connect error and `Obtained_address addr events are only reported if they are distinct from the most recent event of the same type that has taken place since the most recent `Attempting_to_connect event.

connected returns the first available rpc connection from the time it is called. When currently connected, the returned deferred is already determined. If closed has been called, then the returned deferred is never determined.

val current_connection : t -> conn option

The current rpc connection, if any.

val close : t -> unit Async_extra.Import.Deferred.t

close t closes the current connection and stops it from trying to reconnect. After the deferred it returns becomes determined, the last connection has been closed and no others will be attempted.

is_closed t returns true if close has ever been called, even if the returned deferred has not yet been fulfilled.

close_finished t becomes determined at the same time as the result of the first call to close. close_finished differs from close in that it does not have the side effect of initiating a close.

val is_closed : t -> bool
val close_finished : t -> unit Async_extra.Import.Deferred.t