#dynamodb #rusoto #rusoto-dynamodb

macro dynomite-derive

Derives AWS DynamoDB dynomite types from native Rust struct types

21 unstable releases (9 breaking)

0.10.0 Sep 6, 2020
0.9.0 Jul 14, 2020
0.8.2 Jun 4, 2020
0.7.0 Nov 3, 2019
0.1.3 Mar 8, 2018

#302 in Rust patterns

Download history 347/week @ 2021-09-29 411/week @ 2021-10-06 578/week @ 2021-10-13 407/week @ 2021-10-20 206/week @ 2021-10-27 229/week @ 2021-11-03 579/week @ 2021-11-10 364/week @ 2021-11-17 481/week @ 2021-11-24 606/week @ 2021-12-01 439/week @ 2021-12-08 386/week @ 2021-12-15 407/week @ 2021-12-22 400/week @ 2021-12-29 475/week @ 2022-01-05 334/week @ 2022-01-12

1,698 downloads per month
Used in dynomite

MIT license

23KB
461 lines

🦀🧨

dynomite

dynomite makes DynamoDB fit your types (and visa versa)


Overview

Goals

  • ⚡ make writing dynamodb applications in rust a productive experience
  • 🦀 exploit rust's type safety features
  • 👩‍💻 leverage existing work of the rusoto rust project
  • ☔ commitment to supporting applications built using stable rust
  • 📚 commitment to documentation

Features

  • 💌 less boilerplate
  • ♻️ automatic async pagination
  • 🕶️ client level retry interfaces for robust error handling

From this

use std::collections::HashMap;
use rusoto_dynamodb::AttributeValue;
use uuid::Uuid;

let mut item = HashMap.new();
item.insert(
  "pk".to_string(), AttributeValue {
    s: Some(Uuid::new_v4().to_hyphenated().to_string()),
    ..AttributeValue::default()
  }
);
item.insert(
  // 🤬typos anyone?
  "quanity".to_string(), AttributeValue {
    n: Some("whoops".to_string()),
    ..AttributeValue::default()
  }
);

To this

use dynomite::Item;
use uuid::Uuid;

#[derive(Item)]
struct Order {
  #[dynomite(partition_key)]
  pk: Uuid,
  quantity: u16
}

let item = Order {
  pk: Uuid::new_v4(),
  quantity: 4
}.into();

Please see the API documentation for how to get started. Enjoy.

📦 Install

In your Cargo.toml file, add the following under the [dependencies] heading

dynomite = "0.10"

🤸 Examples

You can find some example application code under dynomite/examples

DynamoDB local

AWS provides a convenient way to host a local instance of DynamoDB for testing.

Here is a short example of how to get up a testing locally quickly with both dynomite as well as rusoto_dynamodb.

In one terminal spin up a Docker container for DynamoDB local listening on port 8000

$ docker run --rm -p 8000:8000 amazon/dynamodb-local

In another, run a rust binary with a client initialized like you see the the local.rs example

Resources

Doug Tangren (softprops) 2018-2020

Dependencies

~330–760KB
~18K SLoC

ÛfT_