forked from lei.chen/myxce
feat(libxce-failover): reconnect/rejoin hook — public setter + post-reconnect invocation before resume (task 4.1)
This commit is contained in:
parent
12284bc3f5
commit
8783ce5a9d
6 changed files with 264 additions and 26 deletions
|
|
@ -11,6 +11,18 @@
|
|||
|
||||
typedef void* xcecli_ctx_t;
|
||||
|
||||
/*
|
||||
* xcecli_reconnect_cb: consumer rejoin hook invoked once per transparent
|
||||
* reconnect/failover, AFTER the reconnect/recovery and BEFORE the interrupted
|
||||
* op resumes. The callback CONTENT (join handshake, worker job re-sync) belongs
|
||||
* to the consumer; libxce owns only the mechanism + ordering. Runs on the
|
||||
* calling thread. Return 0 to proceed with the interrupted op; <0 to treat the
|
||||
* rejoin as failed (the new primary rejected the join) so the failover loop
|
||||
* rotates/backs off again instead of resuming. Pure clients register NO hook
|
||||
* (NULL) — the loop then resumes directly.
|
||||
*/
|
||||
typedef int (*xcecli_reconnect_cb)(xcecli_ctx_t ctx, void* arg);
|
||||
|
||||
#define N_MAX_MASTERS (3)
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -26,6 +38,8 @@ typedef struct {
|
|||
extern int xcecli_ctx_init(xcecli_ctx_t*, xce_client_config_t*);
|
||||
extern void xcecli_ctx_fini(xcecli_ctx_t);
|
||||
extern int xcecli_set_handler(xcecli_ctx_t, xce_request_handler_t, void*);
|
||||
extern int xcecli_set_reconnect_handler(xcecli_ctx_t, xcecli_reconnect_cb,
|
||||
void*);
|
||||
extern int xcecli_start(xcecli_ctx_t);
|
||||
extern int xcecli_stop(xcecli_ctx_t);
|
||||
extern int xcecli_wakeup(xcecli_ctx_t, int);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue