Crates.io | dynamo-subscriber |
lib.rs | dynamo-subscriber |
version | 0.1.1 |
source | src |
created_at | 2023-11-27 14:31:59.231829 |
updated_at | 2023-11-28 11:25:39.65594 |
description | Subscribe DynamoDB Streams as tokio-stream |
homepage | |
repository | https://github.com/kaicoh/dynamo-subscriber |
max_upload_size | |
id | 1050486 |
size | 62,275 |
Subscribe DynamoDB Streams as tokio-stream.
This library is a wrapper of DynamoDB Streams and enables using it as a tokio-stream. If you want to know what tokio-stream is and how to use it, see this doc.
In this example, the stream object subscribes dynamodb stream and receives records from it.
[dependencies]
dynamo-subscriber = "0.1.0"
aws-config = "1.0.1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
tokio-stream = "0.1.14"
use aws_config::BehaviorVersion;
use dynamo_subscriber as subscriber;
use tokio_stream::StreamExt;
// This example assumes that the dynamodb-local instance is running on localhost:8000
// and "People" table exists.
#[tokio::main]
async fn main() {
let config = aws_config::load_defaults(BehaviorVersion::latest())
.await
.into_builder()
.endpoint_url("http://localhost:8000")
.build();
let client = subscriber::Client::new(&config);
let mut stream = subscriber::stream::builder()
.table_name("People")
.client(client)
.build();
while let Some(records) = stream.next().await {
println!("{:#?}", records);
}
}
This project is licensed under the MIT license.