pub struct RunningSystem<Sub: Send + 'static> { /* private fields */ }Expand description
A running local agent system: the router task plus handles for feeding it input, attaching subscribers, and observing thread lifecycle.
The system runs until shutdown consumes it: individual
threads idle out (and respawn on demand) while the router keeps running, so
sending to a thread never races a teardown.
Sub is the observer’s
SubscribeRequest type.
Implementations§
Source§impl<Sub: Send + 'static> RunningSystem<Sub>
impl<Sub: Send + 'static> RunningSystem<Sub>
Sourcepub fn sender(&self) -> ChannelSender
pub fn sender(&self) -> ChannelSender
The system’s InputSender, for callback
servers and any other external message injectors.
Sourcepub async fn send(&self, message: InputMessage, dedup_id: &str)
pub async fn send(&self, message: InputMessage, dedup_id: &str)
Deliver an input message to its thread (message.group_id).
dedup_id should be stable across redeliveries of the same message.
Sourcepub async fn send_user_text(
&self,
thread_id: &ThreadId<str>,
text: impl Into<String>,
)
pub async fn send_user_text( &self, thread_id: &ThreadId<str>, text: impl Into<String>, )
Convenience: send plain user text to a thread.
Sourcepub async fn subscribe(&self, thread_id: &ThreadId<str>, request: Sub)
pub async fn subscribe(&self, thread_id: &ThreadId<str>, request: Sub)
Attach a subscriber to a thread; resolves once the subscriber is
installed. See SubscribeHandle::subscribe.
Sourcepub fn subscribe_handle(&self) -> SubscribeHandle<Sub>
pub fn subscribe_handle(&self) -> SubscribeHandle<Sub>
A clonable handle for attaching subscribers (see
SubscribeHandle::subscribe).
Sourcepub fn is_idle(&self) -> bool
pub fn is_idle(&self) -> bool
Whether no thread driver is currently live. Threads with active subscriptions but no pending work do not count as live; their events respawn a driver when they arrive.
Sourcepub async fn next_lifecycle_event(&mut self) -> Option<ThreadLifecycleEvent>
pub async fn next_lifecycle_event(&mut self) -> Option<ThreadLifecycleEvent>
Wait for the next thread-driver lifecycle transition. Returns None
after the router shuts down and all lifecycle senders are dropped.
Sourcepub fn try_next_lifecycle_event(
&mut self,
) -> Result<ThreadLifecycleEvent, TryRecvError>
pub fn try_next_lifecycle_event( &mut self, ) -> Result<ThreadLifecycleEvent, TryRecvError>
Return the next queued lifecycle transition without waiting.