-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.mli
47 lines (38 loc) · 1.43 KB
/
server.mli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
open Request_vote_rpc
open Append_entries_rpc
open Lwt
(* Represents a server which manages
its own state. Thus, the server
defines the set of valid functions
on a state, and stores the server's
own information that cannot be
transformed.
*)
(* Follower, Candidate, Leader *)
type role
(* = | Follower | Candidate | Leader *)
(* State representation *)
type state
(* Gets the IP of this server *)
val get_my_addr: unit -> Unix.inet_addr
(* Returns a string upon receiving a message *)
val handle_message: string -> Lwt_io.output_channel -> unit
(* return a state with a new randomized heartbeat when a node transitions from a
* candidate to a follower *)
val change_heartbeat: unit -> unit
(* [req_append_entries str] sends an appendEntries call to another server
* [str] is the message we want to send
*)
val req_append_entries : append_entries_req -> string -> Lwt_io.output_channel -> unit Lwt.t
(* [res_append_entries str] sends an appendEntries call to another server
* [str] is the message we want to send
*)
val res_append_entries : append_entries_res -> Lwt_io.output_channel -> unit Lwt.t
(* [req_request_vote str] sends an requestVote call
* [str] is the message we want to send
*)
val req_request_vote : vote_req -> Lwt_io.output_channel -> unit Lwt.t
(* [res_request_vote str] sends an requestVote call
* [str] is the message we want to send
*)
val res_request_vote : Yojson.Basic.json -> Lwt_io.output_channel -> unit Lwt.t