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
//! JetStream support with builder pattern.
//!
//! This module provides typed JetStream operations including:
//!
//! - Stream creation and management with builder pattern
//! - Push and pull consumers
//! - Interest-based consumers
//! - Work queues
//!
//! # Example
//!
//! ```no_run
//! use intercom::{Client, MsgPackCodec, jetstream::stream::StreamConfig};
//! use serde::{Deserialize, Serialize};
//!
//! #[derive(Serialize, Deserialize, Debug)]
//! struct Event {
//! id: u64,
//! data: String,
//! }
//!
//! # async fn example() -> intercom::Result<()> {
//! let client = Client::<MsgPackCodec>::connect("nats://localhost:4222").await?;
//! let jetstream = client.jetstream();
//!
//! // Create a stream with builder pattern
//! let stream = jetstream
//! .stream_builder("events")
//! .subjects(vec!["events.>".to_string()])
//! .max_messages(1_000_000)
//! .create()
//! .await?;
//!
//! // Publish typed messages
//! jetstream.publish::<Event>("events.user", &Event {
//! id: 1,
//! data: "user created".to_string(),
//! }).await?;
//!
//! // Create a pull consumer
//! let consumer = stream
//! .pull_consumer_builder::<Event>("my-consumer")
//! .durable()
//! .create()
//! .await?;
//! # Ok(())
//! # }
//! ```