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
//! A minimal Kafka service: one `#[subscriber]` handler on one topic.
//!
//! `KafkaBroker::new` is synchronous and does no I/O, so the whole service fits the
//! `#[ruststream::app]` macro. The runtime connects the broker once at startup
//! (`Broker::connect`) before opening subscriptions, and the generated binary understands
//! `run` and `asyncapi gen`.
//!
//! The bare-string subscriber form consumes the topic named `orders` through the broker's
//! default consumer group (Kafka cannot subscribe without a group). Start a broker first:
//!
//! ```text
//! just brokers-up
//! cargo run --example kafka_quickstart -- run
//! ```
//!
//! Publish an order from another terminal:
//!
//! ```text
//! docker exec -i ruststream-kafka /opt/kafka/bin/kafka-console-producer.sh \
//! --bootstrap-server localhost:9092 --topic orders <<< '{"id":1}'
//! ```
// --8<-- [start:handler]
use ;
use subscriber;
use KafkaBroker;
use Deserialize;
async
// --8<-- [end:handler]
// --8<-- [start:app]
// --8<-- [end:app]