pub struct AgentRegistry { /* private fields */ }Expand description
Thread-safe agent registry with parent/child hierarchy and sqlitegraph persistence.
Uses a hybrid approach: in-memory AgentTree for fast reads, write-through to
sqlitegraph on register and disconnect. On startup, agents are loaded from
the database — all agents start offline and must re-register.
Implementations§
Source§impl AgentRegistry
impl AgentRegistry
Sourcepub fn new(graph: &SqliteGraph) -> Result<Self>
pub fn new(graph: &SqliteGraph) -> Result<Self>
Create a new registry, loading existing agents from the database. All agents from the DB start in offline state — they must re-register. Only agents that were explicitly retired before shutdown have their IDs added to the reuse pool. Agents that are simply offline after restart keep their IDs reserved until they re-register or are explicitly retired.
Sourcepub fn register(
&self,
graph: &SqliteGraph,
name: &str,
kind: &str,
parent_id: Option<String>,
) -> Result<AgentInfo>
pub fn register( &self, graph: &SqliteGraph, name: &str, kind: &str, parent_id: Option<String>, ) -> Result<AgentInfo>
Register an agent and return its server-assigned ID.
If an active agent with the same name already exists (and no parent_id is specified), the existing agent is returned — registration is idempotent. This lets agents reconnect without creating duplicates.
For subagents (parent_id provided), a new child agent is always created
with a hierarchical ID like id1.1, id1.2, etc.
Sourcepub fn retire(&self, graph: &SqliteGraph, agent_id: &str) -> Result<Vec<String>>
pub fn retire(&self, graph: &SqliteGraph, agent_id: &str) -> Result<Vec<String>>
Retire an agent and all descendants. Retired IDs are added to the reuse pool. Returns list of affected IDs.
Sourcepub fn disconnect(
&self,
graph: &SqliteGraph,
agent_id: &str,
) -> Result<Vec<String>>
pub fn disconnect( &self, graph: &SqliteGraph, agent_id: &str, ) -> Result<Vec<String>>
Disconnect agent — marks agent and descendants as Retired. Kept for backward compatibility with DELETE /agents/{id}.
pub fn get(&self, agent_id: &str) -> Result<AgentInfo>
pub fn list_all(&self) -> Result<Vec<AgentInfo>>
pub fn is_active(&self, agent_id: &str) -> Result<bool>
pub fn list_active(&self) -> Result<Vec<AgentInfo>>
pub fn get_children(&self, agent_id: &str) -> Result<Vec<AgentInfo>>
Sourcepub fn heartbeat(
&self,
graph: &SqliteGraph,
agent_id: &str,
status: AgentStatusSnapshot,
) -> Result<()>
pub fn heartbeat( &self, graph: &SqliteGraph, agent_id: &str, status: AgentStatusSnapshot, ) -> Result<()>
Record a heartbeat, updating the agent’s status snapshot and timestamp.
Sourcepub fn get_stale_agents(&self, threshold_minutes: i64) -> Result<Vec<AgentInfo>>
pub fn get_stale_agents(&self, threshold_minutes: i64) -> Result<Vec<AgentInfo>>
Return active agents whose last heartbeat is older than threshold_minutes.
Sourcepub fn purge_retired(&self, threshold_hours: i64) -> Result<usize>
pub fn purge_retired(&self, threshold_hours: i64) -> Result<usize>
Remove retired agents that haven’t heartbeated in 24+ hours. Returns the number of purged agents.
Auto Trait Implementations§
impl !RefUnwindSafe for AgentRegistry
impl !UnwindSafe for AgentRegistry
impl Freeze for AgentRegistry
impl Send for AgentRegistry
impl Sync for AgentRegistry
impl Unpin for AgentRegistry
impl UnsafeUnpin for AgentRegistry
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
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
Source§fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
Source§fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
x-request-id as the header name. Read moreSource§fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
Source§fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
x-request-id as the header name. Read more