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
impl OutboundRoutes
Sourcepub fn new(db: &AimDb, scheme: &str) -> DbResult<Self>
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.
Sourcepub fn routes(&self) -> &[RouteInfo]
pub fn routes(&self) -> &[RouteInfo]
Routes, for parsing per-route configuration once at build.
Sourcepub fn stats(&self, id: RouteId) -> Option<RouteStats>
pub fn stats(&self, id: RouteId) -> Option<RouteStats>
Values taken from route id’s buffer so far, by outcome.
Sourcepub fn poll_stage(&mut self, cx: &mut Context<'_>) -> Poll<Option<RouteId>>
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 routeidis staged; take it withtake_staged. A staged message that was never taken is returned again, not replaced.Ready(None): every route is closed, or there were none. Final: aselectarm 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.
Sourcepub fn take_staged(&mut self) -> Option<OutboundMessage<'_>>
pub fn take_staged(&mut self) -> Option<OutboundMessage<'_>>
Lend the staged message and clear it. None if nothing is staged.
Sourcepub fn reject(&mut self, id: RouteId)
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.
Sourcepub fn poll_next(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Option<OutboundMessage<'_>>>
pub fn poll_next( &mut self, cx: &mut Context<'_>, ) -> Poll<Option<OutboundMessage<'_>>>
poll_stage, then take_staged,
for hand-written poll code.
Sourcepub async fn next(&mut self) -> Option<OutboundMessage<'_>>
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.