Allow configuration of dynamodb storage to specify the max retries of aws sdk (#4115)
This commit is contained in:
parent
0b62264b68
commit
475d5910e8
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue