Skip to main content

Module etcd

Module etcd 

Source
Expand description

etcd-backed config store for HA clustering.

Talks to etcd’s v3 HTTP/JSON gateway (the /v3/kv/* and /v3/auth/authenticate endpoints) through the shared OutboundClient — no gRPC, protoc, or tonic dependency. Config lives under per-resource keys (<prefix>/routes/<name>, <prefix>/policies/<name>, <prefix>/consumers/<name>), each value the resource’s JSON. Every gateway instance loads from the same prefix and a background poll task keeps the cluster converged (see spawn_watch).

§Route ordering

etcd returns keys in lexicographic order, so in etcd mode routes are matched by name order, not file declaration order. Name routes accordingly when precedence matters.

§v1 limitations (documented follow-ups)

  • Plaintext / no TLS to etcd (loopback or private-network etcd).
  • Poll-based convergence (default 2 s) rather than a streaming watch.
  • Uses the first endpoint; multi-endpoint failover is a later addition.

Structs§

EtcdConfigStore
etcd config store over the v3 HTTP/JSON gateway.

Enums§

EtcdCallError 🔒
Internal call-error type distinguishing a 401 (triggers re-auth) from other failures.

Functions§

build_source
Builds the etcd store and the initial gateway config.
gateway_from_kvs 🔒
Assembles a GatewayConfig from the etcd key/value pairs under prefix.
is_empty 🔒
prefix_range_end 🔒
Computes etcd’s prefix range-end: the prefix with its last non-0xff byte incremented (so a Range covers all keys starting with the prefix). An all-0xff prefix ranges to the end of the keyspace ([0]).
spawn_watch
Spawns the poll-based convergence task: every poll_interval (default 2 s) it reloads from etcd and, when the config changed, applies it. Errors are logged and retried on the next tick — a transient etcd outage leaves the last-good config serving.