RPC procedures are now identified via a struct containing a string name.
[invirt/third/libt4.git] / paxos_protocol.h
1 #ifndef paxos_protocol_h
2 #define paxos_protocol_h
3
4 #include "types.h"
5 #include "rpc/rpc.h"
6
7 struct prop_t {
8     unsigned n;
9     string m;
10
11     MEMBERS(n, m)
12     LEXICOGRAPHIC_COMPARISON(prop_t)
13 };
14
15 namespace paxos_protocol {
16     enum status : rpc_protocol::status { OK, ERR };
17     struct prepareres {
18         enum { reject, oldinstance, accept } type;
19         prop_t n_a;
20         string v_a;
21
22         MEMBERS(type, n_a, v_a)
23     };
24     using node_t = string;
25     using nodes_t = std::vector<node_t>;
26     using value_t = string;
27
28     REMOTE_PROCEDURE_BASE(0x11000);
29     REMOTE_PROCEDURE(1, preparereq, (prepareres &, node_t, unsigned, prop_t));
30     REMOTE_PROCEDURE(2, acceptreq, (bool &, node_t, unsigned, prop_t, value_t));
31     REMOTE_PROCEDURE(3, decidereq, (int &, node_t, unsigned, value_t));
32     REMOTE_PROCEDURE(4, heartbeat, (int &, string, unsigned));
33 }
34
35 #endif