Skip to content

Commit a5c2641

Browse files
committed
feat: remove github.com/hashicorp/go-retryablehttp dependency
1 parent 201b8cb commit a5c2641

File tree

2 files changed

+25
-32
lines changed

2 files changed

+25
-32
lines changed

cmd/idpscimcli/cmd/aws.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ func runAWSServiceConfig(_ *cobra.Command, _ []string) error {
9393
defer cancel()
9494

9595
httpRetryClient := httpretrier.NewClient(
96-
3, // Max Retries
97-
httpretrier.ExponentialBackoff(10*time.Millisecond, 100*time.Millisecond),
96+
10, // Max Retries
97+
httpretrier.ExponentialBackoff(10*time.Millisecond, 500*time.Millisecond),
9898
nil, // Use http.DefaultTransport
9999
)
100100

@@ -125,10 +125,11 @@ func runAWSGroupsList(_ *cobra.Command, _ []string) error {
125125
httpTransport.MaxConnsPerHost = 100
126126
httpTransport.MaxIdleConnsPerHost = 100
127127

128-
httpClient := &http.Client{
129-
Transport: httpTransport,
130-
Timeout: maxTimeout,
131-
}
128+
httpClient := httpretrier.NewClient(
129+
10, // Max Retries
130+
httpretrier.ExponentialBackoff(10*time.Millisecond, 500*time.Millisecond),
131+
httpTransport,
132+
)
132133

133134
awsSCIMService, err := aws.NewSCIMService(httpClient, cfg.AWSSCIMEndpoint, cfg.AWSSCIMAccessToken)
134135
if err != nil {
@@ -158,10 +159,11 @@ func runAWSUsersList(_ *cobra.Command, _ []string) error {
158159
httpTransport.MaxConnsPerHost = 100
159160
httpTransport.MaxIdleConnsPerHost = 100
160161

161-
httpClient := &http.Client{
162-
Transport: httpTransport,
163-
Timeout: maxTimeout,
164-
}
162+
httpClient := httpretrier.NewClient(
163+
10, // Max Retries
164+
httpretrier.ExponentialBackoff(10*time.Millisecond, 500*time.Millisecond),
165+
httpTransport,
166+
)
165167

166168
awsSCIMService, err := aws.NewSCIMService(httpClient, cfg.AWSSCIMEndpoint, cfg.AWSSCIMAccessToken)
167169
if err != nil {

internal/setup/setup.go

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
"github.com/aws/aws-sdk-go-v2/service/s3"
1313
"github.com/aws/aws-sdk-go-v2/service/secretsmanager"
14-
"github.com/hashicorp/go-retryablehttp"
14+
"github.com/p2p-b2b/httpretrier"
1515
"github.com/pkg/errors"
1616
"github.com/slashdevops/idp-scim-sync/internal/config"
1717
"github.com/slashdevops/idp-scim-sync/internal/core"
@@ -216,15 +216,11 @@ func SyncService(ctx context.Context, cfg *config.Config) (*core.SyncService, er
216216
gwsServiceAccountContent = gwsServiceAccount
217217
}
218218

219-
idpClient := retryablehttp.NewClient()
220-
idpClient.RetryMax = 5
221-
idpClient.RetryWaitMin = time.Millisecond * 200
222-
// set the logger only in debug mode
223-
if cfg.Debug {
224-
idpClient.Logger = slog.Default()
225-
} else {
226-
idpClient.Logger = nil
227-
}
219+
idpClient := httpretrier.NewClient(
220+
10, // Max Retries
221+
httpretrier.ExponentialBackoff(10*time.Millisecond, 500*time.Millisecond),
222+
nil, // Use http.DefaultTransport
223+
)
228224

229225
userAgent := fmt.Sprintf("idp-scim-sync/%s", version.Version)
230226

@@ -233,7 +229,7 @@ func SyncService(ctx context.Context, cfg *config.Config) (*core.SyncService, er
233229
ServiceAccount: gwsServiceAccountContent,
234230
Scopes: cfg.GWSServiceAccountScopes,
235231
UserAgent: userAgent,
236-
Client: idpClient.StandardClient(),
232+
Client: idpClient,
237233
}
238234

239235
// Google Client Service
@@ -257,18 +253,13 @@ func SyncService(ctx context.Context, cfg *config.Config) (*core.SyncService, er
257253
// AWS SCIM Service
258254

259255
// httpClient
260-
scimClient := retryablehttp.NewClient()
261-
scimClient.RetryMax = 10
262-
scimClient.RetryWaitMin = time.Millisecond * 100
263-
264-
// set the logger only in debug mode
265-
if cfg.Debug {
266-
scimClient.Logger = slog.Default()
267-
} else {
268-
scimClient.Logger = nil
269-
}
256+
scimClient := httpretrier.NewClient(
257+
10, // Max Retries
258+
httpretrier.ExponentialBackoff(10*time.Millisecond, 500*time.Millisecond),
259+
nil, // Use http.DefaultTransport
260+
)
270261

271-
awsSCIM, err := aws.NewSCIMService(scimClient.StandardClient(), cfg.AWSSCIMEndpoint, cfg.AWSSCIMAccessToken)
262+
awsSCIM, err := aws.NewSCIMService(scimClient, cfg.AWSSCIMEndpoint, cfg.AWSSCIMAccessToken)
272263
if err != nil {
273264
return nil, errors.Wrap(err, "cannot create aws scim service")
274265
}

0 commit comments

Comments
 (0)