pub trait StateStore: Send + Sync {
type NodeId: Eq + Hash + Clone + Send + Sync;
type State: Clone + Send + Sync;
type Error: Send + Sync + 'static;
// Required methods
fn get(&self, id: &Self::NodeId) -> Result<Option<Self::State>, Self::Error>;
fn put(
&self,
id: &Self::NodeId,
state: Self::State,
) -> Result<(), Self::Error>;
fn remove(&self, id: &Self::NodeId) -> Result<(), Self::Error>;
fn list(&self) -> Result<Vec<(Self::NodeId, Self::State)>, Self::Error>;
}Expand description
Generic key-value store for per-node runtime state (latency, quotas, counters, etc.).
Strategies read state through trait bounds on node types (e.g., LoadMetric).
StateStore is the persistence layer: the library ships InMemoryStore; users can
implement this for Redis, etcd, or any other backend.
Required Associated Types§
type NodeId: Eq + Hash + Clone + Send + Sync
type State: Clone + Send + Sync
type Error: Send + Sync + 'static
Required Methods§
Sourcefn get(&self, id: &Self::NodeId) -> Result<Option<Self::State>, Self::Error>
fn get(&self, id: &Self::NodeId) -> Result<Option<Self::State>, Self::Error>
Fetch the state for a single node, or None if absent.
Sourcefn put(&self, id: &Self::NodeId, state: Self::State) -> Result<(), Self::Error>
fn put(&self, id: &Self::NodeId, state: Self::State) -> Result<(), Self::Error>
Insert or overwrite the state for a node.