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

Allow configuration of dynamodb storage to specify the max retries of aws sdk #4115

Merged
merged 5 commits into from
Mar 19, 2018
Merged
Changes from 4 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
15 changes: 14 additions & 1 deletion physical/dynamodb/dynamodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,18 @@ func NewDynamoDBBackend(conf map[string]string, logger log.Logger) (physical.Bac
}
}

dynamodbMaxRetryString := os.Getenv("AWS_DYNAMODB_MAX_RETRIES")
if dynamodbMaxRetryString == "" {
dynamodbMaxRetryString = conf["dynamodb_max_retries"]
if dynamodbMaxRetryString == "" {
dynamodbMaxRetryString = "-1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the aws sdk const name, not the value.

}
}
dynamodbMaxRetry, err := strconv.Atoi(dynamodbMaxRetryString)
if err != nil {
return nil, fmt.Errorf("invalid max retry: %s", dynamodbMaxRetryString)
}

credsConfig := &awsutil.CredentialsConfig{
AccessKey: accessKey,
SecretKey: secretKey,
Expand All @@ -202,7 +214,8 @@ func NewDynamoDBBackend(conf map[string]string, logger log.Logger) (physical.Bac
WithEndpoint(endpoint).
WithHTTPClient(&http.Client{
Transport: pooledTransport,
})
}).
WithMaxRetries(dynamodbMaxRetry)
client := dynamodb.New(session.New(awsConf))

if err := ensureTableExists(client, table, readCapacity, writeCapacity); err != nil {
Expand Down