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

This commit is contained in:
Nicholas Watkins 2018-03-19 14:53:23 -05:00 committed by Jeff Mitchell
parent 0b62264b68
commit 475d5910e8
1 changed files with 15 additions and 1 deletions

View File

@ -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,
@ -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 {