Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to put together a couple of examples. Need help. #1910

Closed
jwhance opened this issue Feb 7, 2021 · 6 comments
Closed

Trying to put together a couple of examples. Need help. #1910

jwhance opened this issue Feb 7, 2021 · 6 comments

Comments

@jwhance
Copy link

jwhance commented Feb 7, 2021

First of all, Rust noob here so that may be a part of the problem. I'm trying to branch off from the "Hello world" track and do something with Rusoto and DynamoDb. I didn't have too much trouble with the simple snippet on the docs.rs page:

https://docs.rs/rusoto_dynamodb/0.46.0/rusoto_dynamodb/

But things went downhill quickly when I tried to actually do something else. I turned to the "tests" at:

https://github.com/rusoto/rusoto/blob/master/helpers/tests/dynamodb.rs

and I found some material there that helped a lot but there are some things that don't work and I'm at a loss to understand why. Here are my issues and thanks in advance for any advice...

  1. The code at https://github.com/rusoto/rusoto/blob/master/helpers/tests/dynamodb.rs has Key on line 20 but this fails and I cannot find this symbol in the Rusoto source code. What is the source of this and why does it appear in the tests but not work when I try to reference it from my code?

I worked around this by using a HashMap<String, AttributeValue> in its p[lace but I'm like to understand what's going on here.

  1. Possibly related to this is the same section of source code but lines 66-68:
    let mut item = Key::default();
    item.insert("string".to_string(), val!(S => "foo"));
    item.insert("number".to_string(), val!(N => "1234"));

Key appears here again but it's the val! that is confusing me. What is val! and how do I use it? I find the string val! noplace in the Rusoto source but here. I used the following code to work around this but it baffles me:

    let mut key: HashMap<String, AttributeValue> = HashMap::new();
    key.insert(
        String::from("SensorId"),
        AttributeValue {
            s: Some(String::from("28-000006b4e9ca")), // In this case SensorId is an "S"
            ..Default::default() // The rest of the fields in the AttributeValue struct are set to default
        },
    );
@matthewkmayer
Copy link
Member

👋 The helpers crate hasn't been updated or touched in years and isn't supported.

The best reference is the integration tests for DynamoDB but it only does table level interactions.

My recommendation is to use dynomite for DynamoDB interaction. I'm not sure if it's updated to use the latest Rusoto release, so that's something to check.

For an example of using dynomite with previous releases of Rusoto and dynomite, check out refeed-rampage for upsert, fetch and delete via dynomite.

@jwhance
Copy link
Author

jwhance commented Feb 7, 2021

Thanks for the reply. I had seen the integration tests but, as you mentioned, it leaves out too many details. I had not come across the dynomite yet as the rusoto is all that comes back on searches.

@jwhance
Copy link
Author

jwhance commented Feb 7, 2021

So I guess this raises a follow-up question in my mind. Is Rusoto a dead-end at this point or is it just the DynamoDb section that is outdated? I ask because I have been working heavily with AWS for the past couple of years (using Python and boto3) and was hoping to leverage some of the AWS experience to help me get into Rust.

If Rusoto is not the boto3 of Rust is there something else I should be looking at? It appears there is a relatively complete set of AWS services covered in Rusoto and I only started with the DynamoDb part because that was what was in the example on the Rusoto home page at: https://www.rusoto.org/usage-and-example.html

@matthewkmayer
Copy link
Member

It may help to think of Rusoto as botocore instead of boto3. The helpers crate you found was intended to the higher level boto3 equivalent but the project isn't there yet.

Rusoto works with DynamoDB and dynomite work, but examples are lacking and some documentation links are outdated. Sadly you've come across the worst of it. There are issues open for fixing this such as #1814 but they have not been done.

Rusoto is in maintenance mode. While much functionality is present and working, due to lack of financial and time support, not a lot of work is being done right now. About a year ago Amazon posted multiple job openings for Rust SDK development but we've seen nothing yet aside from comments such as we'd like to be helpful there. It's probably hard for AWS to prioritize creating or supporting a Rust SDK because it makes up such a small fraction of their users.

Even with the rough edges present in Rusoto, it's been used in production for years by many AWS customers.

As for other projects available, there's mostly S3 interactions available in other crates like https://github.com/paolobarbolini/rusty-s3 and https://github.com/durch/rust-s3.

@matthewkmayer
Copy link
Member

@jwhance
Copy link
Author

jwhance commented Feb 8, 2021

Thanks for the help! In spite of the issues I was able to have success with DynamoDb get_item, put_item, and query.

@jwhance jwhance closed this as completed Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants