pub struct ReferenceRing { /* private fields */ }Expand description
Daemon-warm, actor-scoped recently-referenced ring.
Privacy is structural: rings are keyed by (namespace, actor) and a
snapshot for one actor never observes another actor’s entries, even
within the same namespace.
Implementations§
Source§impl ReferenceRing
impl ReferenceRing
pub fn new() -> Self
pub fn with_bounds(capacity: usize, ttl: Duration) -> Self
pub fn with_bounds_and_outer_limit( capacity: usize, ttl: Duration, max_outer_keys: usize, ) -> Self
Sourcepub fn admit(
&self,
namespace: &str,
actor: &str,
id: Uuid,
name: Option<String>,
)
pub fn admit( &self, namespace: &str, actor: &str, id: Uuid, name: Option<String>, )
Admit id into the (namespace, actor) ring, touching it to “now”.
Re-admitting an id already present moves it to the back (most-recent)
instead of duplicating the entry. Eviction is size-or-age, then the
outer map itself is pruned (see prune_outer_map) so it never grows
without bound.
Sourcepub fn snapshot(&self, namespace: &str, actor: &str) -> Vec<RingEntry>
pub fn snapshot(&self, namespace: &str, actor: &str) -> Vec<RingEntry>
Snapshot the live (non-stale) entries for (namespace, actor),
most-recently-touched first. Returns an empty vec for an unknown or
empty key: never an error, since a ring miss is always legitimate
(fresh session, restarted daemon, cross-actor query).
Also runs prune_outer_map over the whole outer map, not just the
queried key: otherwise a daemon that only ever reads (never admits)
would never prune any other actor’s stale key.