2 releases
0.1.1 | Nov 28, 2023 |
---|---|
0.1.0 | Nov 27, 2023 |
#1579 in Database interfaces
54KB
988 lines
dynamo-subscriber
Subscribe DynamoDB Streams as tokio-stream.
Overview
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.
Example
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);
}
}
License
This project is licensed under the MIT license.
Dependencies
~19–26MB
~342K SLoC