feat(libxce-failover): foundation — per-ctx failover state, redirect-hint fields, remove orphaned retry primitive (task 1.1)
This commit is contained in:
parent
8c11655e53
commit
387ccfa8dc
17 changed files with 2122 additions and 562 deletions
63
src/lib/client_internal.h
Normal file
63
src/lib/client_internal.h
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#if !defined(_CLIENT_INTERNAL_H_)
|
||||
|
||||
#define _CLIENT_INTERNAL_H_ 1
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "client.h"
|
||||
#include "mylock.h"
|
||||
#include "netio.h"
|
||||
#include "request.h"
|
||||
#include "xcectx.h"
|
||||
|
||||
/*
|
||||
* client_internal.h — private libxce client state shared between client.c and
|
||||
* the forthcoming failover helper (client_failover.c, task 1.x).
|
||||
*
|
||||
* api_ctx_t was previously file-local to client.c. It is moved here so the
|
||||
* failover helper can operate on it without exposing it through the public
|
||||
* API in client.h.
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
API_CTX_INIT = 0,
|
||||
API_CTX_RUN,
|
||||
API_CTX_DOWN,
|
||||
API_CTX_ERR
|
||||
} api_ctx_state_t;
|
||||
|
||||
/*
|
||||
* xcecli_reconnect_cb: consumer rejoin hook invoked after a transparent
|
||||
* reconnect/failover and before the in-flight request resumes. NULL for pure
|
||||
* clients (e.g. xce_test). The public declaration and the
|
||||
* xcecli_set_reconnect_handler() setter are introduced by a later task; this
|
||||
* private typedef lets the failover state carry the hook now.
|
||||
*/
|
||||
typedef int (*xcecli_reconnect_cb)(xcecli_ctx_t c, void* arg);
|
||||
|
||||
/*
|
||||
* xce_failover_state_t: per-context failover state. Persists across calls so a
|
||||
* sticky primary and the retry tunables survive between requests.
|
||||
*
|
||||
* lock — serializes xcecli_* per ctx (shared-ctx safety)
|
||||
* cur_master — index into conf->masters[] (sticky primary)
|
||||
* retry — defaults from XCE_RETRY_DEFAULTS unless overridden
|
||||
* rejoin_cb — consumer rejoin hook; NULL for pure clients
|
||||
* rejoin_arg — opaque argument passed to rejoin_cb
|
||||
*/
|
||||
typedef struct {
|
||||
mylock_t lock;
|
||||
int cur_master;
|
||||
xce_retry_config_t retry;
|
||||
xcecli_reconnect_cb rejoin_cb;
|
||||
void* rejoin_arg;
|
||||
} xce_failover_state_t;
|
||||
|
||||
typedef struct {
|
||||
xce_client_config_t* conf;
|
||||
endpoint_t ep;
|
||||
xce_ctx_t ctx;
|
||||
xce_failover_state_t failover;
|
||||
} api_ctx_t;
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue