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
|
|
@ -4,6 +4,7 @@
|
|||
#include <sys/socket.h>
|
||||
|
||||
#include "client.h"
|
||||
#include "client_internal.h"
|
||||
#include "controller.capnp.h"
|
||||
#include "mylock.h"
|
||||
|
||||
|
|
@ -13,19 +14,6 @@
|
|||
#include "xcectx.h"
|
||||
#include "xlist.h"
|
||||
|
||||
typedef enum {
|
||||
API_CTX_INIT = 0,
|
||||
API_CTX_RUN,
|
||||
API_CTX_DOWN,
|
||||
API_CTX_ERR
|
||||
} api_ctx_state_t;
|
||||
|
||||
typedef struct {
|
||||
xce_client_config_t* conf;
|
||||
endpoint_t ep;
|
||||
xce_ctx_t ctx;
|
||||
} api_ctx_t;
|
||||
|
||||
int xcecli_ctx_init(xcecli_ctx_t* c, xce_client_config_t* cfg)
|
||||
{
|
||||
api_ctx_t* ctx;
|
||||
|
|
@ -126,6 +114,20 @@ int xcecli_start(xcecli_ctx_t c)
|
|||
return rc;
|
||||
}
|
||||
|
||||
/* Initialize per-context failover state: sticky primary starts at
|
||||
* masters[0] (the initial connect target above), retry tunables default
|
||||
* to XCE_RETRY_DEFAULTS, and no rejoin hook is installed for pure clients.
|
||||
*/
|
||||
rc = mylock_init(&(ctx->failover.lock));
|
||||
if (rc < 0) {
|
||||
endpoint_fini(&(ctx->ep));
|
||||
return rc;
|
||||
}
|
||||
ctx->failover.cur_master = 0;
|
||||
ctx->failover.retry = XCE_RETRY_DEFAULTS;
|
||||
ctx->failover.rejoin_cb = NULL;
|
||||
ctx->failover.rejoin_arg = NULL;
|
||||
|
||||
rc = xce_ctx_start(&(ctx->ctx));
|
||||
|
||||
return rc;
|
||||
|
|
@ -141,6 +143,7 @@ int xcecli_stop(xcecli_ctx_t c)
|
|||
|
||||
xce_ctx_stop(&(ctx->ctx));
|
||||
endpoint_fini(&(ctx->ep));
|
||||
mylock_fini(&(ctx->failover.lock));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue