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
//! The ergonomic bus surface: `send`/`listen` (point-to-point commands) and
//! `publish`/`subscribe` (fan-out events), mirroring the Node `servicebus`
//! family (`rabbitbus`/`kafkabus`/`knativebus`).
//!
//! The surface is split so producing (uniform across every transport) and
//! consuming (a `run_source` loop for pull transports, but generated manifests
//! for Knative) stay coherent:
//!
//! - [`Bus`] — produce: `send` a command, `publish` an event. Every transport.
//! - [`BusConsumer`] — consume: `listen` for commands (competing), `subscribe`
//! to events (fan-out). Pull transports only (in-memory, NATS, RabbitMQ,
//! Kafka, Postgres). Knative consumes via generated Triggers + the HTTP
//! ingress, so it implements only [`Bus`].
//!
//! A concrete `*Bus` implements both, so `bus.send/listen/publish/subscribe` all
//! work on it. `send`/`publish` lower to the transport's [`AsyncMessagePublisher`];
//! `listen`/`subscribe` build the transport's [`AsyncMessageSource`] with the
//! right topology and run it through the shared [`run_source`](super::run_source).
use Future;
use Arc;
use ;
/// Produce side of the bus — uniform across every transport.
/// Consume side of the bus — pull transports that run a [`run_source`] loop.
///
/// `listen`/`subscribe` derive the message names from the router's registered
/// handlers ([`MessageRouter::subscription_plan`]), build the transport's source
/// with the matching topology, and run it. Both run until the source drains/stops.
///
/// [`run_source`]: super::run_source