package shuttle_http

  1. Overview
  2. Docs

Persistent clients, not to be confused with HTTP/1.1 persistent connections are durable clients that maintain a connection to a service and eagerly and repeatedly reconnect if the underlying socket connection is lost.

type t
val sexp_of_t : t -> Sexplib0.Sexp.t
val create : ?random_state:[ `Non_random | `State of Core.Random.State.t ] -> ?retry_delay:(unit -> Core.Time_ns.Span.t) -> ?time_source:Async.Time_source.t -> ?ssl:Ssl.t -> server_name:string -> (unit -> Address.t Async.Deferred.Or_error.t) -> t

Create a new persistent http connection. Random state is forwarded to async and is used to randomize how long to wait between re-connection attempts. A user provided callback is used to retrieve the address to connect to. Users can use this to potentially maintain a pool of service address to target, and decide to use a new target address if the underlying tcp connection is closed.

val closed : t -> unit Async.Deferred.t

closed returns a deferred that's resolved when the http client is closed.

val is_closed : t -> bool

is_closed returns if the client has been closed.

val close : t -> unit Async.Deferred.t

close tears down the persistent connection. The deferred returned will resolve once the underlying http connection is closed.

call Attempts to perform a HTTP request using the user provided client. If the underlying http connection has closed between two calls, and the user hasn't called close on the persistent connection, this function will initiate a new http connection and then perform the http client call.


Innovation. Community. Security.