Skip to main content

OwnershipTable

Struct OwnershipTable 

Source
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

Source

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.

Source

pub fn scopes(&self) -> &[Scope]

Iterate over declared scopes (read-only). Mostly useful for INFO-style telemetry.

Source

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.

Source

pub fn len(&self) -> usize

Number of declared scopes.

Source

pub fn is_empty(&self) -> bool

true when no scopes are declared (the keyspace runs in pre-Phase-3 mode by default).

Source

pub fn lookup(&self, key: &[u8]) -> Option<&Scope>

Longest-prefix match: the most specific scope that owns key, or None when no scope matches.

Source

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).

Source

pub fn route_with_fallback_state<'a, F>( &'a self, key: &[u8], self_node_id: &str, is_writer_down: F, ) -> Routing<'a>
where F: FnMut(&str) -> bool,

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

Source§

fn clone(&self) -> OwnershipTable

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OwnershipTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.