pub struct OwnershipTable { /* private fields */ }Expand description
Immutable ownership table. Build once at startup from
[[cluster.scope]] config; share across reactor threads via
Arc<OwnershipTable>.
Implementations§
Source§impl OwnershipTable
impl OwnershipTable
Sourcepub fn new(scopes: Vec<Scope>) -> Result<Self, OwnershipError>
pub fn new(scopes: Vec<Scope>) -> Result<Self, OwnershipError>
Validate + sort the scope list. Rejects duplicate prefixes and
strict overlap (T3.6 linter). O(n²) over the scope list,
which is tiny (~ N scopes per cluster); no need for a trie at
startup time.
Sourcepub fn scopes(&self) -> &[Scope]
pub fn scopes(&self) -> &[Scope]
Iterate over declared scopes (read-only). Mostly useful for
INFO-style telemetry.
Sourcepub fn scopes_without_fallback(&self) -> Vec<&Scope>
pub fn scopes_without_fallback(&self) -> Vec<&Scope>
T3.13 linter: scopes that declared no fallback. The server
emits a WARN log per entry at boot so operators are aware
that this scope has zero availability if its writer dies —
not an error (the operator may have explicitly chosen
availability < strict ownership), just a heads-up.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
true when no scopes are declared (the keyspace runs in
pre-Phase-3 mode by default).
Sourcepub fn lookup(&self, key: &[u8]) -> Option<&Scope>
pub fn lookup(&self, key: &[u8]) -> Option<&Scope>
Longest-prefix match: the most specific scope that owns
key, or None when no scope matches.
Sourcepub fn route<'a>(&'a self, key: &[u8], self_node_id: &str) -> Routing<'a>
pub fn route<'a>(&'a self, key: &[u8], self_node_id: &str) -> Routing<'a>
Route key from the local node’s perspective. Treats the
declared writer as the active owner; F4 fallback handling is
layered on top in the server’s cement (this fn doesn’t know
about live kevy-elect state — pure config view).
Sourcepub fn route_with_fallback_state<'a, F>(
&'a self,
key: &[u8],
self_node_id: &str,
is_writer_down: F,
) -> Routing<'a>
pub fn route_with_fallback_state<'a, F>( &'a self, key: &[u8], self_node_id: &str, is_writer_down: F, ) -> Routing<'a>
Fallback-aware routing: when writer_down is true for the
matched scope’s writer, the fallback (if declared) is treated
as the active owner. Used by the cement after kevy-elect
flags the writer DOWN (F4).
is_writer_down(node_id) -> bool is a callback so kevy-scope
stays elect-agnostic; the cement plugs in its live snapshot.
Trait Implementations§
Source§impl Clone for OwnershipTable
impl Clone for OwnershipTable
Source§fn clone(&self) -> OwnershipTable
fn clone(&self) -> OwnershipTable
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more