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
//! # DynamodbStream
//!
//! [`DynamodbStream`](crate::stream::DynamodbStream) represents Amazon DynamoDB Streams and you can receive records from it by
//! using it as a [tokio stream](https://docs.rs/tokio-stream/0.1.14/tokio_stream/index.html).
//!
//! ```rust,no_run
//! # use aws_config::BehaviorVersion;
//! use dynamo_subscriber as subscriber;
//! use tokio_stream::StreamExt;
//!
//! # async fn wrapper() {
//! # let config = aws_config::load_defaults(BehaviorVersion::latest()).await;
//! # let client = subscriber::Client::new(&config);
//! // Create a stream from builder.
//! let mut stream = subscriber::stream::builder()
//! .client(client)
//! .table_name("People")
//! .build();
//!
//! // Subscribe the stream to receive DynamoDB Streams records.
//! while let Some(records) = stream.next().await {
//! println!("{:#?}", records);
//! }
//! # }
//! ```
//!
//! ## Stop polling the DynamoDB table
//!
//! Once you construct a stream, it polls the DynamoDB table and receives records permanently.
//! If you want to stop polling, extract a communication channel to the polling half of the
//! stream, and then send `Stop polling` event from the channel.
//!
//! ```rust,no_run
//! # use aws_config::BehaviorVersion;
//! use dynamo_subscriber as subscriber;
//! use tokio_stream::StreamExt;
//!
//! # async fn wrapper() {
//! # let config = aws_config::load_defaults(BehaviorVersion::latest()).await;
//! # let client = subscriber::Client::new(&config);
//! // Create a stream from builder.
//! let mut stream = subscriber::stream::builder()
//! .client(client)
//! .table_name("People")
//! .build();
//!
//! // Extract a communication channel from the stream.
//! let mut channel = stream.take_channel().unwrap();
//!
//! // Receive records from the stream.
//! let records = stream.next().await;
//! println!("{:#?}", records);
//!
//! // Send `Stop polling` event from the communication channel.
//! channel.close(|| {});
//!
//! // Now the stream is closed and no more records can be sent to the stream.
//! let records = stream.next().await;
//! assert!(records.is_none());
//! # }
//! ```
use ;
pub use ConsumerChannel;
pub use ;
/// Create [`DynamodbStreamBuilder`].