Skip to content

Commit 3b85ccf

Browse files
committed
PR feedback, use max retries from configuration
1 parent 0a78c99 commit 3b85ccf

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

pkg/backends/cloudwatch/cloudwatch.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ const MAX_DIMENSIONS = 10
2525
// BackendName is the name of this backend.
2626
const BackendName = "cloudwatch"
2727

28-
type ApiClient interface {
28+
type CloudwatchClient interface {
2929
PutMetricData(context.Context, *cloudwatch.PutMetricDataInput, ...func(*cloudwatch.Options)) (*cloudwatch.PutMetricDataOutput, error)
3030
}
3131

3232
// Client is an object that is used to send messages to AWS CloudWatch.
3333
type Client struct {
3434
logger logrus.FieldLogger
3535

36-
cloudwatch ApiClient
36+
cloudwatch CloudwatchClient
3737
namespace string
3838

3939
disabledSubtypes gostatsd.TimerSubtypes
@@ -60,7 +60,7 @@ func NewClient(namespace, transport string, disabled gostatsd.TimerSubtypes, log
6060
if err != nil {
6161
return nil, err
6262
}
63-
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithHTTPClient(httpClient.Client))
63+
cfg, err := config.LoadDefaultConfig(context.Background(), config.WithHTTPClient(httpClient.Client))
6464
if err != nil {
6565
return nil, err
6666
}

pkg/backends/cloudwatch/cloudwatch_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
)
1818

1919
type mockedCloudwatch struct {
20-
ApiClient
20+
CloudwatchClient
2121

2222
PutMetricDataHandler func(*cloudwatch.PutMetricDataInput) (*cloudwatch.PutMetricDataOutput, error)
2323
}

pkg/cloudproviders/aws/aws.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,22 +242,22 @@ func NewProviderFromViper(v *viper.Viper, logger logrus.FieldLogger, _ string) (
242242
return nil, err
243243
}
244244

245-
cfg, err := config.LoadDefaultConfig(context.TODO(),
245+
cfg, err := config.LoadDefaultConfig(context.Background(),
246246
config.WithHTTPClient(&http.Client{
247247
Transport: transport,
248248
Timeout: httpTimeout,
249249
}),
250-
config.WithRetryMaxAttempts(5),
250+
config.WithRetryMaxAttempts(a.GetInt("max_retries")),
251251
)
252252

253253
metadataClient := imds.NewFromConfig(cfg)
254254

255-
region, err := metadataClient.GetRegion(context.TODO(), nil)
255+
region, err := metadataClient.GetRegion(context.Background(), nil)
256256
if err != nil {
257257
return nil, fmt.Errorf("error getting AWS region: %v", err)
258258
}
259259

260-
ec2config, err := config.LoadDefaultConfig(context.TODO(),
260+
ec2config, err := config.LoadDefaultConfig(context.Background(),
261261
config.WithHTTPClient(&http.Client{
262262
Transport: transport,
263263
Timeout: httpTimeout,

0 commit comments

Comments
 (0)