Skip to main content

RunningSystem

Struct RunningSystem 

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

Source

pub fn sender(&self) -> ChannelSender

The system’s InputSender, for callback servers and any other external message injectors.

Source

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.

Source

pub async fn send_user_text( &self, thread_id: &ThreadId<str>, text: impl Into<String>, )

Convenience: send plain user text to a thread.

Source

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.

Source

pub fn subscribe_handle(&self) -> SubscribeHandle<Sub>

A clonable handle for attaching subscribers (see SubscribeHandle::subscribe).

Source

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.

Source

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.

Source

pub fn try_next_lifecycle_event( &mut self, ) -> Result<ThreadLifecycleEvent, TryRecvError>

Return the next queued lifecycle transition without waiting.

Source

pub async fn shutdown(self)

Wind the whole system down (process exit): every driver interrupts its in-flight completion (flushing pending history to the store) and exits; resolves when the wind-down is complete.

Auto Trait Implementations§

§

impl<Sub> Freeze for RunningSystem<Sub>

§

impl<Sub> RefUnwindSafe for RunningSystem<Sub>

§

impl<Sub> Send for RunningSystem<Sub>

§

impl<Sub> Sync for RunningSystem<Sub>

§

impl<Sub> Unpin for RunningSystem<Sub>

§

impl<Sub> UnsafeUnpin for RunningSystem<Sub>

§

impl<Sub> UnwindSafe for RunningSystem<Sub>

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> 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, 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, 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> 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