pub struct Locality(/* private fields */);Expand description
Opaque process-local affinity assigned once to each participating thread.
It carries no authorization or accounting meaning. Components reduce it modulo their effective shard count, so one lookup can consistently select the lease, rate-limit, and observability shards for a request.
Implementations§
Source§impl Locality
impl Locality
Sourcepub const OBSERVER: Self
pub const OBSERVER: Self
The affinity a control-plane read uses.
Reading published state is not request work and must not spend a
number: every affinity the control plane takes displaces a
request-serving thread onto a shard one of its peers already holds, and
SnapshotManager observing its own publications is exactly how that
happened (GL-124).
It aliases shard zero under every layout, deliberately. A reader that wants the generation, the validity bound or the presence of an entry gets the same answer from any shard, so there is nothing to choose between them — and a constant cannot drift the way “whichever number this thread happens to hold” does.
Sourcepub fn current() -> Self
pub fn current() -> Self
The calling thread’s affinity, assigned on its first use and fixed for the thread’s life.
Sourcepub fn assigned() -> usize
pub fn assigned() -> usize
How many affinities this process has handed out.
Control plane only — no policy decision reads it, and it is relaxed because it answers “roughly how crowded is this instance”, never “which shard is this request on”.
Sourcepub fn index(self, sharding: LocalSharding) -> usize
pub fn index(self, sharding: LocalSharding) -> usize
The shard this affinity selects under sharding: always below
LocalSharding::get.