dynamo_subscriber/
lib.rs

1//! Wrap [Amazon DynamoDB Streams](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/streamsmain.html)
2//! and use it as [Rust Stream](https://docs.rs/futures-core/0.3.29/futures_core/stream/trait.Stream.html).
3//!
4//! ## Getting Started
5//!
6//! A simple example is as follows. Edit your **Cargo.toml** at first.
7//!
8//! ```toml
9//! [dependencies]
10//! dynamo-subscriber = "0.1"
11//! aws-config = "1.0.1"
12//! tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
13//! tokio-stream = "0.1.14"
14//! ```
15//!
16//! Then in code, assuming that the dynamodb-local instance is running on localhost:8000
17//! and "People" table exists, you can subscribe dynamodb streams from "People" table with
18//! the following.
19//!
20//! This stream emits a vector of [`Record`](aws_sdk_dynamodbstreams::types::Record).
21//!
22//! ```rust,no_run
23//! use aws_config::BehaviorVersion;
24//! use dynamo_subscriber as subscriber;
25//! use tokio_stream::StreamExt;
26//!
27//! #[tokio::main]
28//! async fn main() {
29//!     let config = aws_config::load_defaults(BehaviorVersion::latest())
30//!         .await
31//!         .into_builder()
32//!         .endpoint_url("http://localhost:8000")
33//!         .build();
34//!
35//!     let client = subscriber::Client::new(&config);
36//!     let mut stream = subscriber::stream::builder()
37//!         .table_name("People")
38//!         .client(client)
39//!         .build();
40//!
41//!     while let Some(records) = stream.next().await {
42//!         println!("{:#?}", records);
43//!     }
44//! }
45//! ```
46//!
47//! ## AWS SDK Dependency
48//!
49//! To build [`Client`] of this crate, you must pass the reference for
50//! [`SdkConfig`](aws_config::SdkConfig).
51
52#[macro_use]
53mod macros;
54
55/// Client for calling AWS APIs.
56pub mod client;
57
58/// Common errors.
59pub mod error;
60
61/// Data structures used by operations.
62pub mod types;
63
64/// Implementation for Dynamodb Streams.
65pub mod stream;
66
67pub use client::{Client, DynamodbClient};