Trait KeyspaceNode

Source
pub trait KeyspaceNode:
    Debug
    + Hash
    + PartialEq
    + Eq {
    type Id: Debug + Hash + PartialEq + Eq + Clone;

    // Required method
    fn id(&self) -> Self::Id;

    // Provided method
    fn capacity(&self) -> usize { ... }
}
Expand description

Node that stores data.

Node controls one or more intervals of the keyspace. Keys which fall into such an interval are routed to the node (and its replicas).

Required Associated Types§

Required Methods§

Source

fn id(&self) -> Self::Id

Returns the unique identifier of the node.

Provided Methods§

Source

fn capacity(&self) -> usize

Capacity of the node.

The capacity is used to determine what portion of the keyspace the node will control. Since nodes are attached to keyspace portions using Highest Random Weight algorithm (HRW), the capacity affects the score of the node, thus the higher the capacity, the more likely the node will be chosen.

Capacities of all nodes are summed up to determine the total capacity of the keyspace. The relative capacity of the node is then ratio of the node’s capacity to the total capacity of the keyspace.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl KeyspaceNode for str

Source§

type Id = String

Source§

fn id(&self) -> String

Source§

impl KeyspaceNode for String

Source§

type Id = String

Source§

fn id(&self) -> String

Source§

impl<'a, T: 'a + KeyspaceNode + ?Sized> KeyspaceNode for &'a T
where &'a T: Debug + Hash + PartialEq + Eq,

Source§

type Id = <T as KeyspaceNode>::Id

Source§

fn id(&self) -> Self::Id

Source§

fn capacity(&self) -> usize

Implementors§