Documentation
¶
Overview ¶
Package tenant resolves, deterministically and without any coordinator, which replica of the unified cloud binary OWNS the single writer for a tenant's per-tenant SQLite (HIP-0302). Every replica computes the SAME answer from the SAME membership set, so there is no election, no lock service, no discovery.
This is the load-bearing primitive of the horizontally-scalable OSS cloud: N stateless copies of the binary behind one load balancer, each able to say "who writes tenant T?" identically. The owner holds T's DB open (SQLite WAL = 1 writer + N readers) and streams the WAL to SeaweedFS/S3 (HIP-0107); every other replica serves reads from the S3-synced copy or forwards strong writes to the owner.
Ownership uses Rendezvous (Highest-Random-Weight) hashing, not a hash ring: HRW gives minimal reshuffling on membership change (only the tenants owned by a departed replica move, and they spread evenly over the survivors) with no virtual-node bookkeeping — a pure function of (tenant, members).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Member ¶
type Member struct {
ID string // stable replica identity (pod name / node id)
Addr string // reachable address for write-forwarding (host:port)
}
Member is one replica in the live membership set. ID must be stable for the life of the replica (e.g. the pod name or a persistent node id) — HRW weights are derived from it, so a changing ID would reshuffle ownership needlessly.
func Owner ¶
Owner returns the replica that owns the writer for tenantID, or ok=false when members is empty. Deterministic: same (tenantID, members) → same Owner on every replica, regardless of member order.
func Replicas ¶
Replicas returns the top-n members for tenantID by descending HRW weight — the owner first, then the ordered failover successors. On owner loss, the next replica in this list becomes owner with no recomputation of the rest, so read replicas can pre-warm the S3 copy for their likely-next tenants.