this repo has no description
1type node_id = Node_id of string [@@unboxed]
2
3val node_id_to_string : node_id -> string
4val node_id_of_string : string -> node_id
5val equal_node_id : node_id -> node_id -> bool
6val compare_node_id : node_id -> node_id -> int
7
8type incarnation = Incarnation of int [@@unboxed]
9
10val incarnation_to_int : incarnation -> int
11val incarnation_of_int : int -> incarnation
12val zero_incarnation : incarnation
13val compare_incarnation : incarnation -> incarnation -> int
14val incr_incarnation : incarnation -> incarnation
15
16type addr = Eio.Net.Sockaddr.datagram
17type node_info = { id : node_id; addr : addr; meta : string }
18
19val make_node_info : id:node_id -> addr:addr -> meta:string -> node_info
20
21type member_state = Alive | Suspect | Dead | Left
22
23val member_state_to_string : member_state -> string
24val member_state_to_int : member_state -> int
25val member_state_of_int : int -> member_state
26
27type member_snapshot = {
28 node : node_info;
29 state : member_state;
30 incarnation : incarnation;
31 state_change : Mtime.span;
32}
33
34type protocol_msg =
35 | Ping of { seq : int; target : node_id; sender : node_info }
36 | Ping_req of { seq : int; target : node_id; sender : node_info }
37 | Ack of { seq : int; responder : node_info; payload : string option }
38 | Alive of { node : node_info; incarnation : incarnation }
39 | Suspect of {
40 node : node_id;
41 incarnation : incarnation;
42 suspector : node_id;
43 }
44 | Dead of { node : node_id; incarnation : incarnation; declarator : node_id }
45 | User_msg of { topic : string; payload : string; origin : node_id }
46
47type packet = {
48 cluster : string;
49 primary : protocol_msg;
50 piggyback : protocol_msg list;
51}
52
53type decode_error =
54 | Invalid_magic
55 | Unsupported_version of int
56 | Truncated_message
57 | Invalid_tag of int
58 | Decryption_failed
59 | Msgpack_error of string
60 | Invalid_crc
61
62val decode_error_to_string : decode_error -> string
63
64type send_error = Node_unreachable | Timeout | Connection_reset
65
66val send_error_to_string : send_error -> string
67
68type node_event =
69 | Join of node_info
70 | Leave of node_info
71 | Update of node_info
72 | Suspect_event of node_info
73 | Alive_event of node_info
74
75type config = {
76 bind_addr : string;
77 bind_port : int;
78 node_name : string option;
79 protocol_interval : float;
80 probe_timeout : float;
81 indirect_checks : int;
82 suspicion_mult : int;
83 suspicion_max_timeout : float;
84 retransmit_mult : int;
85 udp_buffer_size : int;
86 tcp_timeout : float;
87 send_buffer_count : int;
88 recv_buffer_count : int;
89 secret_key : string;
90 cluster_name : string;
91 label : string;
92 encryption_enabled : bool;
93 gossip_verify_incoming : bool;
94 gossip_verify_outgoing : bool;
95 max_gossip_queue_depth : int;
96}
97
98val default_config : config
99
100type 'a env = {
101 stdenv : 'a;
102 sw : Eio.Switch.t;
103}
104 constraint
105 'a =
106 < clock : _ Eio.Time.clock
107 ; mono_clock : _ Eio.Time.Mono.t
108 ; net : _ Eio.Net.t
109 ; secure_random : _ Eio.Flow.source
110 ; .. >
111
112type stats = {
113 nodes_alive : int;
114 nodes_suspect : int;
115 nodes_dead : int;
116 msgs_sent : int;
117 msgs_received : int;
118 msgs_dropped : int;
119 queue_depth : int;
120 buffers_available : int;
121 buffers_total : int;
122}
123
124val empty_stats : stats
125
126module Wire : sig
127 type message_type =
128 | Ping_msg
129 | Indirect_ping_msg
130 | Ack_resp_msg
131 | Suspect_msg
132 | Alive_msg
133 | Dead_msg
134 | Push_pull_msg
135 | Compound_msg
136 | User_msg
137 | Compress_msg
138 | Encrypt_msg
139 | Nack_resp_msg
140 | Has_crc_msg
141 | Err_msg
142 | Has_label_msg
143
144 val message_type_to_int : message_type -> int
145 val message_type_of_int : int -> (message_type, int) result
146
147 type ping = {
148 seq_no : int;
149 node : string;
150 source_addr : string;
151 source_port : int;
152 source_node : string;
153 }
154
155 type indirect_ping_req = {
156 seq_no : int;
157 target : string;
158 port : int;
159 node : string;
160 nack : bool;
161 source_addr : string;
162 source_port : int;
163 source_node : string;
164 }
165
166 type ack_resp = { seq_no : int; payload : string }
167 type nack_resp = { seq_no : int }
168 type suspect = { incarnation : int; node : string; from : string }
169
170 type alive = {
171 incarnation : int;
172 node : string;
173 addr : string;
174 port : int;
175 meta : string;
176 vsn : int list;
177 }
178
179 type dead = { incarnation : int; node : string; from : string }
180 type compress = { algo : int; buf : string }
181
182 type push_pull_header = {
183 pp_nodes : int;
184 pp_user_state_len : int;
185 pp_join : bool;
186 }
187
188 type push_node_state = {
189 pns_name : string;
190 pns_addr : string;
191 pns_port : int;
192 pns_meta : string;
193 pns_incarnation : int;
194 pns_state : int;
195 pns_vsn : int list;
196 }
197
198 type protocol_msg =
199 | Ping of ping
200 | Indirect_ping of indirect_ping_req
201 | Ack of ack_resp
202 | Nack of nack_resp
203 | Suspect of suspect
204 | Alive of alive
205 | Dead of dead
206 | User_data of string
207 | Compound of string list
208 | Compressed of compress
209 | Err of string
210end
211
212val ip_to_bytes : Eio.Net.Ipaddr.v4v6 -> string
213val ip_of_bytes : string -> Eio.Net.Ipaddr.v4v6
214val default_vsn : int list
215
216val node_info_to_wire :
217 node_info -> source_node:string -> string * int * string * string
218
219val node_info_of_wire :
220 name:string -> addr:string -> port:int -> meta:string -> node_info
221
222val msg_to_wire :
223 self_name:string -> self_port:int -> protocol_msg -> Wire.protocol_msg
224
225val msg_of_wire : default_port:int -> Wire.protocol_msg -> protocol_msg option