Skip to main content

WorkerTaskDelivery

Trait WorkerTaskDelivery 

Source
pub trait WorkerTaskDelivery:
    Send
    + Sync
    + 'static {
    // Required method
    fn deliver<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        worker: &'life1 WorkerHandle,
        task: &'life2 ProtoActivityTask,
        intent: &'life3 SharedDeliveryIntent,
        accepted: &'life4 dyn DeliveryAccepted,
    ) -> Pin<Box<dyn Future<Output = TaskDelivery> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
}
Expand description

A transport that can place one task with one already-selected worker.

🔴 Selection is NOT this trait’s job, and that is the point. The worker arrives already chosen by the dispatcher’s single selection — with its Prefer/Pinned tier walk and placement cache already applied — so a transport cannot select again. Two selections per placement would let the spill resolve differently from the delivery, which is the defect a composite dispatcher would have reintroduced.

Required Methods§

Source

fn deliver<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, worker: &'life1 WorkerHandle, task: &'life2 ProtoActivityTask, intent: &'life3 SharedDeliveryIntent, accepted: &'life4 dyn DeliveryAccepted, ) -> Pin<Box<dyn Future<Output = TaskDelivery> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Deliver task to worker, awaiting whatever that transport’s notion of delivery is.

intent is the caller’s abandonment condition, re-asked while a blocking transport waits for its reply. It is an argument rather than transport state because one of its terms — whether the outbox pass still holds the row’s claim — is unanswerable from inside a transport, and answering it wrongly abandons every dispatcher-originated delivery at its first poll. See DeliveryIntent for the fact that decides it.

It arrives behind an Arc rather than as a bare &dyn because the blocking transport re-asks it on a blocking thread: the wait runs under spawn_blocking, which requires 'static, and a borrow cannot cross that boundary. This is a mechanical requirement of where the predicate is evaluated, not a widening of what it may capture.

accepted is called exactly once, at the instant the transport knows the worker HOLDS the task and before it waits for any reply — the gRPC stream accepted the frame; the liminal push was acknowledged. It is never called for an undeliverable outcome. Production records the attempt’s lease there (WA-010 R3).

Returns TaskDelivery::Delivered when the worker took the task, and TaskDelivery::Undeliverable otherwise — never an error for an ordinary refusal, because the caller’s next move differs by variant and an error type would flatten that distinction back into a comment.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§