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

upgrade aws-sdk-dynamodb dep version #16

Merged
merged 1 commit into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ rusoto_dynamodb = { git = "https://github.com/sportsball-ai/rusoto", rev = "1a6a
bytes = "1.0"
rand = "0.7.3"
base64 = "0.12.2"
aws-sdk-dynamodb = { version = "0.21.0", optional = true }
aws-sdk-dynamodb = { version = "0.24.0", optional = true }

[features]
aws-sdk = ["dep:aws-sdk-dynamodb"]
Expand Down
48 changes: 21 additions & 27 deletions src/aws_sdk_dynamodbstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use aws_sdk_dynamodb::{
AttributeDefinition, BillingMode, Delete, KeySchemaElement, KeyType, KeysAndAttributes, LocalSecondaryIndex, Projection, ProjectionType, Put,
ReturnValue, ScalarAttributeType, Select, TransactWriteItem, Update,
},
types::{Blob, SdkError},
types::Blob,
};
use rand::RngCore;
use simple_error::SimpleError;
Expand Down Expand Up @@ -295,13 +295,11 @@ impl super::Backend for Backend {
.expression_attribute_values(":v", attribute_value(old_value))
.send()
.await
.map_err(|e| e.into_service_error())
{
Ok(_) => Ok(true),
Err(SdkError::ServiceError {
err: PutItemError {
kind: PutItemErrorKind::ConditionalCheckFailedException(_),
..
},
Err(PutItemError {
kind: PutItemErrorKind::ConditionalCheckFailedException(_),
..
}) => Ok(false),
Err(e) => Err(e.into()),
Expand All @@ -317,13 +315,11 @@ impl super::Backend for Backend {
.condition_expression("attribute_not_exists(v)")
.send()
.await
.map_err(|e| e.into_service_error())
{
Ok(_) => Ok(true),
Err(SdkError::ServiceError {
err: PutItemError {
kind: PutItemErrorKind::ConditionalCheckFailedException(_),
..
},
Err(PutItemError {
kind: PutItemErrorKind::ConditionalCheckFailedException(_),
..
}) => Ok(false),
Err(e) => Err(e.into()),
Expand Down Expand Up @@ -899,13 +895,10 @@ impl super::Backend for Backend {
.set_transact_items(Some(transact_items))
.send()
.await
.map_err(|e| e.into_service_error())
{
Err(SdkError::ServiceError {
err:
TransactWriteItemsError {
kind: TransactWriteItemsErrorKind::TransactionCanceledException(cancel),
..
},
Err(TransactWriteItemsError {
kind: TransactWriteItemsErrorKind::TransactionCanceledException(cancel),
..
}) => {
let mut did_fail_conditional = false;
Expand Down Expand Up @@ -977,8 +970,7 @@ mod test {
use crate::{aws_sdk_dynamodbstore, test_backend};
use aws_sdk_dynamodb::{
error::{DescribeTableError, DescribeTableErrorKind},
types::SdkError,
Client, Credentials, Endpoint, Region,
Client, Credentials, Region,
};
use tokio::time;

Expand All @@ -988,7 +980,7 @@ mod test {
let creds = Credentials::new("ACCESSKEYID", "SECRET", None, None, "dummy");
let config = aws_sdk_dynamodb::Config::builder()
.credentials_provider(creds)
.endpoint_resolver(Endpoint::immutable(endpoint.parse().expect("valid URI")))
.endpoint_url(endpoint)
.region(Region::from_static("test"))
.build();
let client = Client::from_conf(config);
Expand All @@ -997,13 +989,15 @@ mod test {

if let Ok(_) = client.delete_table().table_name(table_name).send().await {
for _ in 0..10u32 {
match client.describe_table().table_name(table_name.clone()).send().await {
Err(SdkError::ServiceError {
err:
DescribeTableError {
kind: DescribeTableErrorKind::ResourceNotFoundException(_),
..
},
match client
.describe_table()
.table_name(table_name.clone())
.send()
.await
.map_err(|e| e.into_service_error())
{
Err(DescribeTableError {
kind: DescribeTableErrorKind::ResourceNotFoundException(_),
..
}) => break,
_ => time::sleep(time::Duration::from_millis(200)).await,
Expand Down