package happy-eyeballs

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
module Ip_set : Set.S with type elt = Ipaddr.t

The module of a set of IP addresses.

module Ipv4_set : Set.S with type elt = Ipaddr.V4.t

The module of a set of IPv4 addresses.

module Ipv6_set : Set.S with type elt = Ipaddr.V6.t

The module of a set of IPv6 addresses.

type t

The internal state of happy eyeballs.

type action =
  1. | Resolve_a of [ `host ] Domain_name.t
  2. | Resolve_aaaa of [ `host ] Domain_name.t
  3. | Connect of [ `host ] Domain_name.t * int * Ipaddr.t * int
  4. | Connect_failed of [ `host ] Domain_name.t * int

The variant of actions to be performed by the effectful layer.

val pp_action : action Fmt.t

pp_action ppf a pretty-prints the action a on ppf.

type event =
  1. | Resolved_a of [ `host ] Domain_name.t * Ipv4_set.t
  2. | Resolved_aaaa of [ `host ] Domain_name.t * Ipv6_set.t
  3. | Resolved_a_failed of [ `host ] Domain_name.t
  4. | Resolved_aaaa_failed of [ `host ] Domain_name.t
  5. | Connection_failed of [ `host ] Domain_name.t * int * Ipaddr.t * int
  6. | Connected of [ `host ] Domain_name.t * int * Ipaddr.t * int

The variant of events.

val pp_event : event Fmt.t

pp_event ppf e pretty-prints event e on ppf.

val create : int64 -> t

create ts creates the internal state, initialized with the timestamp ts (an arbitrary number that must be monotonically increasing).

val timer : t -> int64 -> t * action list

timer t ts is a timer function that results in an updated t and a list of actions that need to be performed (connection to be retried, connection failures to be repored, ...)

val connect : t -> int64 -> id:int -> [ `host ] Domain_name.t -> int list -> t * action list

connect t ts ~id host ports attempts a connection to host, where the ports are attempted in sequence. It results in an updated t and a list of actions to be performed.

  • raises Failure

    if ports is the empty list.

val connect_ip : t -> int64 -> id:int -> Ip_set.t -> int list -> t * action list

connect_ip t ts ~id ips ports attempts a connection to ips, ports. The list of ips will be sorted (mixing IPv6 and IPv4 addresses). The ports will be tried in sequence. The result is an updated t and a list of actions to be performed.

  • raises Failure

    if ports is the empty list or ips the empty set.

val event : t -> int64 -> event -> t * action list

event t ts ev results in an updated t and a list of actions to be performed.

  • raises Failure

    if ev contains an empty set of IP addresses.

module Waiter_map : sig ... end

A map for waiters and internal id.