-
Notifications
You must be signed in to change notification settings - Fork 16
/
craq_rpc.x
133 lines (113 loc) · 2.38 KB
/
craq_rpc.x
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/* Basic type definitions
* =============================== */
typedef string rpc_string<255>;
typedef opaque rpc_hash<20>;
typedef opaque blob<>;
/* ====================== */
/* Manager RPC types and functions
* =============================== */
enum event_type {
EVENT_ADD = 0,
EVENT_DEL = 1
};
struct rpc_node {
rpc_string ip;
unsigned port;
rpc_hash id;
};
struct rpc_node_list {
unsigned ver;
rpc_node nodes<>;
};
struct rpc_memb_change {
event_type event;
rpc_node node;
unsigned ver;
};
struct rpc_memb_delta {
rpc_memb_change changes<>;
};
program RPC_MANAGER {
version RPC_MANAGER_VERSION {
void REGISTER(rpc_node) = 0;
rpc_node_list GET_NODE_LIST(void) = 1;
unsigned GET_NODE_LIST_VERSION(void) = 2;
rpc_memb_delta GET_NODE_LIST_DELTA(unsigned) = 3;
void REPORT_BAD(rpc_node) = 4;
} = 1;
} = 31313;
/* ====================== */
/* Chain Node RPC types and functions
* =============================== */
struct head_write_arg {
rpc_hash chain;
rpc_hash id;
blob data;
};
struct propagate_arg {
rpc_hash chain;
rpc_hash id;
unsigned ver;
blob data;
bool committed;
};
struct ack_arg {
rpc_hash chain;
rpc_hash id;
unsigned ver;
};
struct query_obj_ver_arg {
rpc_hash chain;
rpc_hash id;
};
struct query_obj_ver_ret {
int hist;
int pend;
};
struct tail_read_arg {
rpc_hash chain;
rpc_hash id;
};
struct tail_read_ex_arg {
rpc_hash chain;
rpc_hash id;
bool dirty;
};
struct tail_read_ex_ret {
blob data;
bool dirty;
unsigned ver;
};
enum add_chain_ret {
ADD_CHAIN_SUCCESS = 0,
ADD_CHAIN_FAILURE = 1,
ADD_CHAIN_EXISTS = 2
};
struct add_chain_arg {
rpc_hash id;
rpc_string data_centers<>;
unsigned chain_size;
};
struct test_and_set_arg {
rpc_hash chain;
rpc_hash id;
blob data;
unsigned ver;
};
program CHAIN_NODE {
version CHAIN_NODE_VERSION {
/*External functions*/
blob TAIL_READ(rpc_hash) = 0; /* TODO: tail_read_arg */
bool HEAD_WRITE(head_write_arg) = 1;
tail_read_ex_ret TAIL_READ_EX(tail_read_ex_arg) = 8;
add_chain_ret ADD_CHAIN(add_chain_arg) = 9;
bool TEST_AND_SET(test_and_set_arg) = 10;
/*Internal functions*/
bool PROPAGATE(propagate_arg) = 2;
query_obj_ver_ret QUERY_OBJ_VER(rpc_hash) = 3; /* TODO: query_obj_ver_arg */
bool ACK(ack_arg) = 4;
bool BACK_PROPAGATE(propagate_arg) = 6;
bool NO_OP(void) = 7;
} = 1;
} = 21212;
/* ====================== */