Swim.Types

swim · API reference

type node_id = 
  | Node_id of string
val node_id_to_string : node_id -> string
val node_id_of_string : string -> node_id
val equal_node_id : node_id -> node_id -> bool
val compare_node_id : node_id -> node_id -> int
type incarnation = 
  | Incarnation of int
val incarnation_to_int : incarnation -> int
val incarnation_of_int : int -> incarnation
val zero_incarnation : incarnation
val compare_incarnation : incarnation -> incarnation -> int
val incr_incarnation : incarnation -> incarnation
type addr = Eio.Net.Sockaddr.datagram
type node_info = {
  id : node_id;
  addr : addr;
  meta : string;
}
val make_node_info : id:node_id -> addr:addr -> meta:string -> node_info
type member_state = 
  | Alive
  | Suspect
  | Dead
  | Left
val member_state_to_string : member_state -> string
val member_state_to_int : member_state -> int
val member_state_of_int : int -> member_state
type member_snapshot = {
  node : node_info;
  state : member_state;
  incarnation : incarnation;
  state_change : Mtime.span;
}
type protocol_msg = 
  | Ping of {
    seq : int;
    target : node_id;
    sender : node_info;
  }
  | Ping_req of {
    seq : int;
    target : node_id;
    sender : node_info;
  }
  | Ack of {
    seq : int;
    responder : node_info;
    payload : string option;
  }
  | Alive of {
    node : node_info;
    incarnation : incarnation;
  }
  | Suspect of {
    node : node_id;
    incarnation : incarnation;
    suspector : node_id;
  }
  | Dead of {
    node : node_id;
    incarnation : incarnation;
    declarator : node_id;
  }
  | User_msg of {
    topic : string;
    payload : string;
    origin : node_id;
  }
type packet = {
  cluster : string;
  primary : protocol_msg;
  piggyback : protocol_msg list;
}
type decode_error = 
  | Invalid_magic
  | Unsupported_version of int
  | Truncated_message
  | Invalid_tag of int
  | Decryption_failed
  | Msgpack_error of string
  | Invalid_crc
val decode_error_to_string : decode_error -> string
type send_error = 
  | Node_unreachable
  | Timeout
  | Connection_reset
val send_error_to_string : send_error -> string
type node_event = 
  | Join of node_info
  | Leave of node_info
  | Update of node_info
  | Suspect_event of node_info
  | Alive_event of node_info
type config = {
  bind_addr : string;
  bind_port : int;
  node_name : string option;
  protocol_interval : float;
  push_pull_interval : float; (* Seconds between periodic full state exchanges with a random member (anti-entropy; heals divergence missed by the bounded gossip budget). 0 disables. *)
  probe_timeout : float;
  indirect_checks : int;
  suspicion_mult : int;
  suspicion_max_timeout : float;
  retransmit_mult : int;
  udp_buffer_size : int;
  tcp_timeout : float;
  send_buffer_count : int;
  recv_buffer_count : int;
  secret_key : string;
  cluster_name : string;
  label : string;
  encryption_enabled : bool;
  gossip_verify_incoming : bool;
  gossip_verify_outgoing : bool;
  max_gossip_queue_depth : int;
}
val default_config : config
type 'a env = {
  stdenv : 'a;
  sw : Eio.Switch.t;
}
  constraint
    'a =
    < clock : _ Eio.Time.clock
    ; mono_clock : _ Eio.Time.Mono.t
    ; net : _ Eio.Net.t
    ; secure_random : _ Eio.Flow.source.. >
type stats = {
  nodes_alive : int;
  nodes_suspect : int;
  nodes_dead : int;
  msgs_sent : int;
  msgs_received : int;
  msgs_dropped : int;
  queue_depth : int;
  buffers_available : int;
  buffers_total : int;
}
val empty_stats : stats
module Wire : sig ... end
val ip_to_bytes : Eio.Net.Ipaddr.v4v6 -> string
val ip_of_bytes : string -> Eio.Net.Ipaddr.v4v6
val default_vsn : int list
val node_info_to_wire : 
  node_info ->
  source_node:string ->
  string * int * string * string
val node_info_of_wire : 
  name:string ->
  addr:string ->
  port:int ->
  meta:string ->
  node_info
val msg_to_wire : 
  self_name:string ->
  self_port:int ->
  protocol_msg ->
  Wire.protocol_msg
val msg_of_wire : default_port:int -> Wire.protocol_msg -> protocol_msg option