Skip to main content

Relay

Struct Relay 

Source
pub struct Relay {
    pub base_dir: PathBuf,
}
Expand description

The main relay hub. All operations are local filesystem — no network.

Create one per repo/project with a shared base_dir path. Every agent that uses the same path will see each other’s messages.

Fields§

§base_dir: PathBuf

Implementations§

Source§

impl Relay

Source

pub fn new(base_dir: PathBuf) -> Self

Create a new relay rooted at the given directory.

Typical usage: Relay::new(".relay".into()) at the repo root. All agents must use the same path to see each other.

Source

pub fn now() -> u64

Source

pub fn register( &self, agent_id: &str, session_id: &str, pid: u32, ) -> AgentRegistration

Register an agent so others can discover it.

Source

pub fn register_with_metadata( &self, agent_id: &str, session_id: &str, pid: u32, metadata: Value, ) -> AgentRegistration

Register with custom metadata (model name, capabilities, etc).

Source

pub fn heartbeat(&self, session_id: &str)

Update heartbeat to signal this agent is still alive.

Source

pub fn unregister(&self, session_id: &str)

Unregister an agent (cleanup on exit).

Source

pub fn agents(&self) -> Vec<AgentRegistration>

List all registered agents.

Source

pub fn cleanup_dead(&self) -> usize

Remove registrations for agents whose PID is no longer alive.

Source

pub fn send( &self, from_session: &str, from_agent: &str, to_session: Option<&str>, content: &str, ) -> Message

Send a message. to_session: None = broadcast to all agents.

Source

pub fn inbox(&self, session_id: &str, limit: usize) -> Vec<(Message, bool)>

Read inbox: returns messages with a flag indicating if newly read. Marks all returned messages as read by this session.

Source

pub fn unread(&self, session_id: &str) -> Vec<Message>

Get unread messages without marking them as read.

Source

pub fn unread_count(&self, session_id: &str) -> u64

Count unread messages for a session.

Source

pub fn cleanup_old(&self, max_age_secs: u64) -> usize

Delete messages older than max_age_secs.

Source

pub fn poll(&self, session_id: &str) -> u64

Poll for new messages. Returns unread count. Useful for integration: call this in a loop and trigger actions (like spawning a background AI session) when count > 0.

Auto Trait Implementations§

§

impl Freeze for Relay

§

impl RefUnwindSafe for Relay

§

impl Send for Relay

§

impl Sync for Relay

§

impl Unpin for Relay

§

impl UnsafeUnpin for Relay

§

impl UnwindSafe for Relay

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,