type node_id = Node_id of string [@@unboxed] 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 [@@unboxed] 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; 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 type message_type = | Ping_msg | Indirect_ping_msg | Ack_resp_msg | Suspect_msg | Alive_msg | Dead_msg | Push_pull_msg | Compound_msg | User_msg | Compress_msg | Encrypt_msg | Nack_resp_msg | Has_crc_msg | Err_msg | Has_label_msg val message_type_to_int : message_type -> int val message_type_of_int : int -> (message_type, int) result type ping = { seq_no : int; node : string; source_addr : string; source_port : int; source_node : string; } type indirect_ping_req = { seq_no : int; target : string; port : int; node : string; nack : bool; source_addr : string; source_port : int; source_node : string; } type ack_resp = { seq_no : int; payload : string } type nack_resp = { seq_no : int } type suspect = { incarnation : int; node : string; from : string } type alive = { incarnation : int; node : string; addr : string; port : int; meta : string; vsn : int list; } type dead = { incarnation : int; node : string; from : string } type compress = { algo : int; buf : string } type push_pull_header = { pp_nodes : int; pp_user_state_len : int; pp_join : bool; } type push_node_state = { pns_name : string; pns_addr : string; pns_port : int; pns_meta : string; pns_incarnation : int; pns_state : int; pns_vsn : int list; } type protocol_msg = | Ping of ping | Indirect_ping of indirect_ping_req | Ack of ack_resp | Nack of nack_resp | Suspect of suspect | Alive of alive | Dead of dead | User_data of string | Compound of string list | Compressed of compress | Err of string 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