pub struct AgentRegistry<'a> { /* private fields */ }Expand description
The fused agent registry. Two distinct sources kept apart on purpose: the
durable, replayable log card registry (a fold over the
registry topic to the latest card per agent, capability that outlives a brief
disconnect), and the live connection presence (what an agent advertises
right now over AGDX_SET_CLIENT_METADATA, including the inbox topic routing
resolves to, gone on disconnect). Build it with Laser::agent_registry,
refresh to fold new cards, refresh_presence
to pull live presence, then resolve by capability and inbox.
Implementations§
Source§impl<'a> AgentRegistry<'a>
impl<'a> AgentRegistry<'a>
Sourcepub async fn refresh(&mut self, now_micros: u64) -> Result<usize, LaserError>
pub async fn refresh(&mut self, now_micros: u64) -> Result<usize, LaserError>
Fold every card published since the last refresh into the registry,
stamping now_micros as the observation time, and write the result back to
the shared per-stream cache (evicting cards stale at now_micros, so the
cached set stays bounded by live agents). Returns the number of records
folded. A record that is not a status/card/quarantine envelope, or
whose body does not decode, is skipped (the registry topic is single-purpose,
but a stray record must not poison the fold).
Sourcepub fn agents(&self) -> impl Iterator<Item = &RegisteredCard>
pub fn agents(&self) -> impl Iterator<Item = &RegisteredCard>
Every agent with a folded card, newest observation kept, ordered by agent id (byte order), so every SDK lists and routes in the same order.
Sourcepub fn lookup(&self, agent: &AgentId) -> Option<&RegisteredCard>
pub fn lookup(&self, agent: &AgentId) -> Option<&RegisteredCard>
The latest card for agent, if any.
Sourcepub fn resolve(&self, skill_id: &str, now_micros: u64) -> Vec<&RegisteredCard>
pub fn resolve(&self, skill_id: &str, now_micros: u64) -> Vec<&RegisteredCard>
Every agent that advertises skill_id, is still fresh at now_micros, and
is not advertising itself Unavailable for it. The capability-resolution
primitive the router builds on, so a stale or self-declared-unavailable
agent is never routed to. Ordered by agent id (byte order), so
RoutePolicy::Any and ranking ties pick
the same agent in every SDK.
Sourcepub fn is_quarantined(&self, agent: &AgentId) -> bool
pub fn is_quarantined(&self, agent: &AgentId) -> bool
Whether agent has been quarantined by an operator.
Sourcepub fn inbox_for(&self, agent: &AgentId) -> Option<&str>
pub fn inbox_for(&self, agent: &AgentId) -> Option<&str>
The inbox topic agent advertised in its live presence, or None when it
advertised none (or refresh_presence has not
run). The destination an InboxRoute::Advertised
route resolves to, so routing never assumes a shared topic name.
Sourcepub fn inbox_for_principal(
&self,
agent: &AgentId,
principal: PrincipalId,
) -> Option<&str>
pub fn inbox_for_principal( &self, agent: &AgentId, principal: PrincipalId, ) -> Option<&str>
The inbox agent advertised, but only if the connection that advertised it
authenticated as user_id. The principal-bound resolve a deployment with an
enrolled agent-to-principal mapping uses, so a connection cannot route work
to itself by claiming another principal’s agent id. inbox_for
is the claim-only resolve for deployments without such a mapping.
Sourcepub fn principal_for(&self, agent: &AgentId) -> Option<PrincipalId>
pub fn principal_for(&self, agent: &AgentId) -> Option<PrincipalId>
The authenticated principal of the live connection claiming agent.
None means no live presence or a substrate that supplied no principal.
Sourcepub async fn refresh_presence(&mut self) -> Result<usize, LaserError>
pub async fn refresh_presence(&mut self) -> Result<usize, LaserError>
Pull live connection presence and fold it in, keyed by the agent id each
connection claims, so inbox_for can resolve a target
to where it is consuming right now. Reads every page of the client-metadata
discovery command and decodes each connection’s metadata as an
AgentPresence, skipping connections whose metadata is absent or is not a
presence body (the channel is opaque, a non-agent client advertises any
blob). A later connection claiming the same agent id wins, matching
last-write presence. Returns the number of presences folded.
Served by Iggy, so it returns a transport error against a Iggy server that lacks the command.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for AgentRegistry<'a>
impl<'a> !UnwindSafe for AgentRegistry<'a>
impl<'a> Freeze for AgentRegistry<'a>
impl<'a> Send for AgentRegistry<'a>
impl<'a> Sync for AgentRegistry<'a>
impl<'a> Unpin for AgentRegistry<'a>
impl<'a> UnsafeUnpin for AgentRegistry<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.