forked from lei.chen/myxce
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
|
|
@ -176,10 +176,12 @@ extern int xce_upgrade_config_req_extract_raw(const uint8_t *pkt_data,
|
|||
size_t *out_len,
|
||||
uint8_t **out_sha256);
|
||||
|
||||
/* ── Task 10.2: Client-Side Transparent Retry (Req 7.1–7.6) ─────────────────
|
||||
/* ── Client-Side Transparent Retry tunables (Req 6.1, 6.2) ──────────────────
|
||||
*
|
||||
* xce_retry_config_t: configurable retry parameters with safe production defaults.
|
||||
* Pass NULL to xce_request_with_retry() to use defaults.
|
||||
* xce_retry_config_t: configurable retry parameters with safe production
|
||||
* defaults, consumed by the libxce client failover loop (client.c /
|
||||
* client_failover.c). XCE_RETRY_DEFAULTS supplies the defaults applied when no
|
||||
* override is configured.
|
||||
*/
|
||||
typedef struct {
|
||||
int max_retries; /* default 20 */
|
||||
|
|
@ -190,29 +192,4 @@ typedef struct {
|
|||
|
||||
extern const xce_retry_config_t XCE_RETRY_DEFAULTS;
|
||||
|
||||
/*
|
||||
* xce_request_with_retry: transparent retry wrapper for transient controller errors.
|
||||
*
|
||||
* - XCE_ERR_NOT_READY → backoff, retry same endpoint (Req 7.1)
|
||||
* - XCE_ERR_STANDBY with redirect_host/port → reconnect, retry (Req 7.2)
|
||||
* - XCE_ERR_STANDBY without redirect → backoff, retry (Req 7.2 fallback)
|
||||
* - ECONNREFUSED / ETIMEDOUT → reconnect, retry (Req 7.3)
|
||||
* - EPERM / EINVAL / ENOENT / EACCES → surface immediately (Req 7.4)
|
||||
* - Exhausted max_retries → surface last error (Req 7.5)
|
||||
* - Backoff jitter via rand_r() to prevent thundering herd (Req 7.6)
|
||||
*
|
||||
* NULL cfg → uses XCE_RETRY_DEFAULTS.
|
||||
*/
|
||||
extern int xce_request_with_retry(endpoint_t *ep,
|
||||
xce_request_t *req,
|
||||
const xce_retry_config_t *cfg);
|
||||
|
||||
/*
|
||||
* xce_retry_send_hook: test-only injection point for the send+receive round-trip.
|
||||
* When non-NULL, xce_request_with_retry() calls this instead of the real network path.
|
||||
* Returns 0 on success (reply_out populated), -errno on transport failure.
|
||||
*/
|
||||
extern int (*xce_retry_send_hook)(endpoint_t *ep, xce_request_t *req,
|
||||
xce_reply_t *reply_out);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
#define _XCECTX_H_ 1
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "config.h" /* XCE_MAXHOSTNAME_LEN */
|
||||
#include "netio.h"
|
||||
#include "request.h"
|
||||
#include "vtaskmgr.h"
|
||||
|
|
@ -28,6 +31,13 @@ typedef struct {
|
|||
cbuf_t wbuf;
|
||||
dataset_t* dataset;
|
||||
|
||||
/* Redirect-hint address captured from the last redirect reply by
|
||||
* handle_reply() (which only sees xce_ctx_t) and read by the failover
|
||||
* rotator on the next retry. Empty host ("") means no hint. Advisory only;
|
||||
* correctness never depends on it. */
|
||||
char redirect_hint_host[XCE_MAXHOSTNAME_LEN];
|
||||
uint16_t redirect_hint_port;
|
||||
|
||||
struct {
|
||||
union {
|
||||
char* debugmsg;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue