Documentation
¶
Overview ¶
Package replicator is the registrar's cross-region etcd replicator (proposal 006 Phase 2a). Leader-elected (one mirror stream per region), it watches this region's OWN authoritative subtree (<root>/<region>/clusters/<cluster>/…) in the local etcd and replays every change verbatim (Put→Put, Delete→Delete) into each peer region's etcd.
Partitions are origin-first and disjoint, so mirroring is loop-free by construction: a peer's replicator watches only its own subtree and never re-mirrors keys this region wrote into it. Peer registrars see the mirrored keys as read-only foreign endpoints (EDS priority 2, proposal 004 locality).
Every mirrored key is attached to a per-peer origin-heartbeat lease (Phase 2b) that only this replicator's KeepAlive refreshes: if the origin region dies, the lease lapses and the peer drops the whole mirrored subtree together — whole-region failover cleanup without any peer judging the origin dead. Clean shutdown deliberately does NOT revoke the lease (that would wipe the mirror on every leader handoff); the next leader re-syncs under a fresh lease well inside the TTL. See lease.go.
Index ¶
Constants ¶
const DefaultLeaseTTLSeconds = 30
DefaultLeaseTTLSeconds is the origin-heartbeat lease TTL (proposal 006 Phase 2b). It bounds two windows at once: how long a dead origin's mirror lingers on peers (failover cleanup latency) and how long a leader handoff has to re-sync before the mirror expires mid-roll. 30s comfortably covers registrar leader election while keeping whole-region cleanup prompt.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Peer ¶
Peer is one peer region's etcd, the mirror destination.
func ParsePeers ¶
ParsePeers parses repeated --peer-etcd values of the form <region>=<endpoint>[,<endpoint>...] into Peers. The region is the replication unit, so the own region must be explicit (not the single-region default) and peer regions must be distinct from it and from each other.
type Replicator ¶
type Replicator struct {
Source Source
Peers []Peer
Log *slog.Logger
// DialTimeout bounds each peer dial; ResyncBackoff spaces mirror-loop
// restarts after an error; LeaseTTLSeconds is the origin-heartbeat lease
// TTL on each peer (Phase 2b). Zero values take the defaults.
DialTimeout time.Duration
ResyncBackoff time.Duration
LeaseTTLSeconds int64
// contains filtered or unexported fields
}
Replicator mirrors the local own-partition subtree into each peer's etcd. It is a leader-elected manager Runnable: exactly one replica per region holds the mirror streams.
func (*Replicator) NeedLeaderElection ¶
func (r *Replicator) NeedLeaderElection() bool
NeedLeaderElection makes the replicator run only on the elected leader (one mirror stream per origin region; two would double-write peers).