dynamo-subscriber

Crates.iodynamo-subscriber
lib.rsdynamo-subscriber
version0.1.1
sourcesrc
created_at2023-11-27 14:31:59.231829
updated_at2023-11-28 11:25:39.65594
descriptionSubscribe DynamoDB Streams as tokio-stream
homepage
repositoryhttps://github.com/kaicoh/dynamo-subscriber
max_upload_size
id1050486
size62,275
Kanji Tanaka (kaicoh)

documentation

https://docs.rs/dynamo-subscriber

README

dynamo-subscriber

Version License Test

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.

Commit count: 19

cargo fmt