tenant

package
v1.786.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func IsOwner

func IsOwner(tenantID, selfID string, members []Member) bool

IsOwner reports whether selfID owns the writer for tenantID under members. The hot-path check every replica runs per write request.

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

func Owner(tenantID string, members []Member) (Member, bool)

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

func Replicas(tenantID string, members []Member, n int) []Member

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL