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{
|
credsConfig := &awsutil.CredentialsConfig{
|
||||||
AccessKey: accessKey,
|
AccessKey: accessKey,
|
||||||
SecretKey: secretKey,
|
SecretKey: secretKey,
|
||||||
|
@ -202,7 +215,8 @@ func NewDynamoDBBackend(conf map[string]string, logger log.Logger) (physical.Bac
|
||||||
WithEndpoint(endpoint).
|
WithEndpoint(endpoint).
|
||||||
WithHTTPClient(&http.Client{
|
WithHTTPClient(&http.Client{
|
||||||
Transport: pooledTransport,
|
Transport: pooledTransport,
|
||||||
})
|
}).
|
||||||
|
WithMaxRetries(dynamodbMaxRetry)
|
||||||
client := dynamodb.New(session.New(awsConf))
|
client := dynamodb.New(session.New(awsConf))
|
||||||
|
|
||||||
if err := ensureTableExists(client, table, readCapacity, writeCapacity); err != nil {
|
if err := ensureTableExists(client, table, readCapacity, writeCapacity); err != nil {
|
||||||
|
|
Loading…
Reference in a new issue