Skip to main content

OutboundRoutes

Struct OutboundRoutes 

Source
pub struct OutboundRoutes { /* private fields */ }
Expand description

Every outbound link of one scheme, read by the connector’s transport task.

Built in the connector’s build(): cursors start then, so an SPMC ring keeps what is produced before the transport first polls. Only routes whose readers woke are polled, in round-robin order.

Implementations§

Source§

impl OutboundRoutes

Source

pub fn new(db: &AimDb, scheme: &str) -> DbResult<Self>

Subscribes every outbound link of scheme and allocates the scratch once: the largest topic capacity plus the largest payload capacity.

Source

pub fn routes(&self) -> &[RouteInfo]

Routes, for parsing per-route configuration once at build.

Source

pub fn stats(&self, id: RouteId) -> Option<RouteStats>

Values taken from route id’s buffer so far, by outcome.

Source

pub fn poll_stage(&mut self, cx: &mut Context<'_>) -> Poll<Option<RouteId>>

Take the next ready value from a route that woke and serialize it into the scratch. Lends nothing.

  • Ready(Some(id)): a message from route id is staged; take it with take_staged. A staged message that was never taken is returned again, not replaced.
  • Ready(None): every route is closed, or there were none. Final: a select arm must be disarmed after it.
  • Pending: no woken route had a value. On Tokio this can also mean the task’s budget is spent; the task is woken to try again.

A value leaves its buffer only in a call that returns Ready, so this is safe as a select arm. Skipped values (topic overflow, serializer error) and lag are logged and counted in stats.

Source

pub fn take_staged(&mut self) -> Option<OutboundMessage<'_>>

Lend the staged message and clear it. None if nothing is staged.

Source

pub fn reject(&mut self, id: RouteId)

Count a message from route id that the connector took but could not send. The connector logs why; this keeps the count beside the route’s other outcomes.

Source

pub fn poll_next( &mut self, cx: &mut Context<'_>, ) -> Poll<Option<OutboundMessage<'_>>>

poll_stage, then take_staged, for hand-written poll code.

Source

pub async fn next(&mut self) -> Option<OutboundMessage<'_>>

The next message, or None once every route is closed.

Cancel-safe: dropping the future before it completes takes nothing.

Auto Trait Implementations§

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

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.