Skip to content

Commit

Permalink
upgrade aws-sdk-dynamodb dep version (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottlamb authored Feb 3, 2023
1 parent 5e4472b commit e1388dc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 28 deletions.
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

0 comments on commit e1388dc

Please sign in to comment.