forked from Netflix/dynomite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdyn_response_mgr.h
31 lines (27 loc) · 1.26 KB
/
dyn_response_mgr.h
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
#ifndef _DYN_RESPONSE_MGR_H_
#define _DYN_RESPONSE_MGR_H_
#define MAX_REPLICAS_PER_DC 3
struct response_mgr {
bool is_read;
bool done;
/* we could use the dynamic array
here. But we have only 3 ASGs */
struct msg *responses[MAX_REPLICAS_PER_DC];
uint32_t checksums[MAX_REPLICAS_PER_DC];
uint8_t good_responses; // non-error responses received. (nil) is not an error
uint8_t max_responses; // max responses expected.
uint8_t quorum_responses; // responses expected to form a quorum
uint8_t error_responses; // error responses received
struct msg *err_rsp; // first error response
struct conn *conn;
struct msg *msg;
};
void init_response_mgr(struct response_mgr *rspmgr, struct msg*, bool is_read,
uint8_t max_responses, struct conn *conn);
// DN_OK if response was accepted
rstatus_t rspmgr_submit_response(struct response_mgr *rspmgr, struct msg *rsp);
bool rspmgr_check_is_done(struct response_mgr *rspmgr);
struct msg* rspmgr_get_response(struct response_mgr *rspmgr);
void rspmgr_free_response(struct response_mgr *rspmgr, struct msg *dont_free);
void rspmgr_free_other_responses(struct response_mgr *rspmgr, struct msg *dont_free);
#endif