1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//! The gRPC arm of the delivery seam: push the task onto the worker's stream.
//!
//! This is the transport the dispatcher always used, unchanged in what it does
//! — the change is that it now *says* what it did, so the caller acts on a type
//! instead of on the absence of a sender.
use async_trait;
use ProtoActivityTask;
use SharedDeliveryIntent;
use ;
use ;
/// Delivers by pushing a [`WorkerMessage::ActivityTask`] onto the worker's
/// registered stream.
///
/// # Only two outcomes are reachable here, and that is not an oversight
///
/// `mpsc::Sender::send().await` fails **only** when the receiver is gone, i.e.
/// the worker's stream is closed — which is exactly
/// [`Undeliverable::WorkerUnreachable`](super::task_delivery::Undeliverable::WorkerUnreachable).
/// A *full* channel does not error; it applies backpressure and the send waits.
/// So this transport never produces
/// [`DeliveryFailed`](super::task_delivery::Undeliverable::DeliveryFailed).
///
/// I record that because my own design note previously claimed a full channel
/// would map to `DeliveryFailed`. It would — under `try_send`. Under the
/// `send().await` this path has always used, that outcome does not exist, and
/// switching to `try_send` to manufacture it would turn a worker that is merely
/// busy into a failed delivery. `DeliveryFailed` exists for the blocking
/// transport, which really can fail while its worker is alive.
///
/// # The intent is asked once, and the backpressure wait is not re-polled
///
/// The caller's intent is checked immediately before the push. If the caller
/// loses its claim *during* the backpressure wait inside `send().await`, this
/// arm does not notice: there is no poll boundary to re-ask at, and reaching for
/// one would mean abandoning a send mid-flight.
///
/// That is safe, and by two independent mechanisms rather than one:
///
/// 1. **The result cannot be recorded.** The completion token is one per pass,
/// minted by the caller and revoked once when the pass places nothing, so a
/// task that lands after its pass withdrew carries an authorization the
/// fences no longer honour.
/// 2. **The external effect cannot be duplicated.** The task's
/// `idempotency_key` is derived from `(workflow_id, run_id, activity_id)`
/// alone — attempts and execution generations deliberately do not participate
/// (`aion-proto/src/worker.rs:143-146`) — so a redelivery by whichever pass
/// re-claimed the row carries the *same* key and is deduplicated at the
/// worker.
///
/// The token covers the recording, the idempotency key covers the effect. If
/// either ever stops holding, that is a finding about the fences or the key —
/// not a reason to start polling a send.
;