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
//! Direct-transport receive traits.
//!
//! A direct broker client (Postgres, RabbitMQ, Kafka, NATS, or the in-memory
//! dev/test adapter) pulls messages with [`AsyncMessageSource`] and settles each
//! one through [`ReceivedMessage`]. The [`run_source`](super::run_source) runner
//! drives that loop: it dispatches through `Service::dispatch_message` and only
//! then asks the adapter to acknowledge.
//!
//! These are the *direct* receive shape. Knative / HTTP CloudEvents is a
//! separate ingress shape (the platform invokes an endpoint; there is no local
//! poll loop) and is intentionally not modeled through this trait.
use Future;
use ;
/// A transport a runner can pull messages from, one at a time.
///
/// `recv` resolves to:
/// - `Ok(Some(received))` — a message to dispatch and then settle;
/// - `Ok(None)` — the source is drained/closed; the runner stops **gracefully**
/// (this is the shutdown signal — an adapter wires its own stop into `recv`);
/// - `Err(e)` — a transport-level receive failure, surfaced by the runner rather
/// than swallowed.
///
/// The future is `Send` so the runner can be driven on multi-threaded executors.
/// A message received from a transport, plus the means to settle it.
///
/// Settlement consumes the value so a message can be settled exactly once. `ack`
/// and `nack` are the universal primitives every transport supports; an adapter
/// maps them to its native operation (a row completion, a delivery ack, an
/// offset commit, a stream ack, …). `dead_letter` and `park` default to `nack`
/// so a message is never silently dropped; adapters with native dead-letter or
/// parking support should override them.