Skip to content

Commit

Permalink
Allow configuration of dynamodb storage to specify the max retries of…
Browse files Browse the repository at this point in the history
… aws sdk (#4115)
  • Loading branch information
rin1221 authored and jefferai committed Mar 19, 2018
1 parent ba1eb65 commit af974c2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion physical/dynamodb/dynamodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,19 @@ 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"]
}
var dynamodbMaxRetry int = aws.UseServiceDefaultRetries
if dynamodbMaxRetryString != "" {
var err error
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 +215,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

0 comments on commit af974c2

Please sign in to comment.