Skip to main content

Registry

Struct Registry 

Source
pub struct Registry { /* private fields */ }
Expand description

An in-process address book and router over session mailboxes.

Cloneable and shared: every clone refers to the same registry. There is no automatic deregistration — a peer that shuts down stays listed, and a delivery to it fails with RouteError::Closed (a sweep can come later; §10.1 keeps this minimal).

Implementations§

Source§

impl Registry

Source

pub fn new() -> Self

Source

pub fn register(&self, id: SessionId, handle: SessionHandle)

Register a peer’s mailbox at id; re-registering replaces it.

Source

pub fn register_remote(&self, id: SessionId, client: Client)

Register a peer reachable across a socket — a served session this process can message, and which can reach back if it knows us (§8, S4-4).

Source

pub fn locals(&self) -> Vec<(SessionId, SessionHandle)>

The local peers — the in-process handles this registry holds, sorted by address for a deterministic roster. A socket server serves exactly these (Self::registered sessions: the root and its team); a peer reached across a socket (Self::register_remote) is not a local handle and is omitted, so it is never re-served.

Source

pub fn remove(&self, id: &SessionId)

Remove id from the address book and every per-session map, then re-publish the roster.

Drops the id entry from peers (the address book), owners, models, states, efforts, and windows, then calls Self::refresh_roster so every Self::subscriber — a socket server, the TUI — pushes the SHRUNK roster.

§Notes
  • The per-session state watcher register spawned (tokio::spawn of a while state_rx.changed() … loop) ends only when the session drops. It can re-insert a states entry after this returns, but NEVER a peers entry — so Self::locals (which reads peers) stays clean and Self::contains/Self::resolve report the id gone at once. Documented, not fixed (layering: no back-ref).
  • Removing an unknown id is a harmless no-op (refresh_roster still runs).

Not idempotent-erroring and not socket-routed: this is the ROOT-LOCAL retire path (no Request ends a served peer’s session).

Source

pub fn subscribe(&self) -> Receiver<Vec<(SessionId, SessionHandle)>>

A live view of Self::locals: a receiver seeded with the current local roster and updated whenever it changes (a session is registered). A socket server serves it, so a session that appears after the server started is still reachable — see crate::serve.

Source

pub fn contains(&self, id: &SessionId) -> bool

Whether a peer is already registered at id. A plain existence probe — unlike Self::resolve, it needs no from and enforces no permitted set.

Source

pub fn set_owner(&self, worker: SessionId, owner: SessionId)

Record the report_back_to edge: worker reports to owner (its orchestrator). This is the whole ownership tree — a star in v1.

Source

pub fn set_model(&self, id: SessionId, model: impl Into<String>)

Record a session’s effective model id, so the roster this registry feeds (a socket server’s Sessions push) can name it. Mirrors Self::set_owner — a plain metadata write, no effect on routing; it RE-PUBLISHES the roster.

Source

pub fn set_state(&self, id: SessionId, state: MemberState)

Mirror a session’s run-state. Called by the per-session watcher register spawns — NOT by the actor, so the registry keeps NO back-reference into the kernel (layering). Re-publishes the roster, so the socket server pushes the change without polling.

Source

pub fn state_of(&self, id: &SessionId) -> MemberState

The state last mirrored for id; Idle when unknown (a remote peer the registry never watched, or an older server).

Source

pub fn model_of(&self, id: &SessionId) -> Option<String>

The model recorded for id, if any (Self::set_model). None for a peer registered without one (e.g. a remote reached across a socket).

Source

pub fn set_effort(&self, id: SessionId, effort: Option<String>)

Record a session’s effective effort. A metadata write, no routing effect — but it RE-PUBLISHES the roster, so a socket push reflects it.

Source

pub fn effort_of(&self, id: &SessionId) -> Option<String>

The effort last recorded for id; None when unset OR cleared.

Source

pub fn set_context_window(&self, id: SessionId, window: u64)

Record a session’s context window in tokens. RE-PUBLISHES the roster.

Source

pub fn window_of(&self, id: &SessionId) -> Option<u64>

The window last recorded for id; None when unknown.

Source

pub fn set_models(&self, models: Vec<String>)

Record the connection’s model catalog. Does NOT re-publish — the catalog names no session, so it is not roster data.

Source

pub fn models(&self) -> Vec<String>

The recorded catalog (empty when unset — ListModels then answers []).

Source

pub fn permitted(&self, from: &SessionId, to: &SessionId) -> bool

Whether from may address to (§10.1): the pair must be joined by an ownership edge in either direction — an orchestrator and one of its workers. There are no lateral (worker → worker) edges.

Source

pub fn resolve( &self, from: &SessionId, to: &SessionId, ) -> Result<Backend, RouteError>

Resolve to for from, enforcing the permitted set. Fails RouteError::Unknown if no peer is registered, else RouteError::NotPermitted if the sender is out of scope.

Source

pub fn deliver( &self, from: &SessionId, to: &SessionId, request: Request, ) -> Result<(), RouteError>

Deliver a target-side request to to, attributed to from. The recipient sees it as if from had sent it directly (SessionHandle::send_from).

Trait Implementations§

Source§

impl Clone for Registry

Source§

fn clone(&self) -> Self

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 Default for Registry

Source§

fn default() -> Self

Returns the “default value” for a type. 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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WasmCompatSend for T
where T: Send,

Source§

impl<T> WasmCompatSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more