@@ -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/p2p-b2b/httpretrier "
14+ "github.com/hashicorp/go-retryablehttp "
1515 "github.com/pkg/errors"
1616 "github.com/slashdevops/idp-scim-sync/internal/config"
1717 "github.com/slashdevops/idp-scim-sync/internal/core"
@@ -216,16 +216,15 @@ func SyncService(ctx context.Context, cfg *config.Config) (*core.SyncService, er
216216 gwsServiceAccountContent = gwsServiceAccount
217217 }
218218
219- idpClient := httpretrier .NewClientBuilder ().
220- WithTimeout (30 * time .Second ). // Overall request timeout
221- WithMaxRetries (5 ). // Retry up to 3 times
222- WithRetryStrategy (httpretrier .JitterBackoffStrategy ). // Use jitter backoff to avoid thundering herd
223- WithRetryBaseDelay (500 * time .Millisecond ). // Start with 500ms delay (httpretrier default)
224- WithRetryMaxDelay (5 * time .Second ). // Cap at 5 seconds
225- WithMaxIdleConns (10 ). // Max idle connections
226- WithMaxIdleConnsPerHost (10 ). // Max idle connections per host
227- WithIdleConnTimeout (90 * time .Second ). // Idle connection timeout
228- Build ()
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+ }
229228
230229 userAgent := fmt .Sprintf ("idp-scim-sync/%s" , version .Version )
231230
@@ -234,7 +233,7 @@ func SyncService(ctx context.Context, cfg *config.Config) (*core.SyncService, er
234233 ServiceAccount : gwsServiceAccountContent ,
235234 Scopes : cfg .GWSServiceAccountScopes ,
236235 UserAgent : userAgent ,
237- Client : idpClient ,
236+ Client : idpClient . StandardClient () ,
238237 }
239238
240239 // Google Client Service
@@ -257,18 +256,19 @@ func SyncService(ctx context.Context, cfg *config.Config) (*core.SyncService, er
257256
258257 // AWS SCIM Service
259258
260- scimClient := httpretrier .NewClientBuilder ().
261- WithTimeout (30 * time .Second ). // Overall request timeout
262- WithMaxRetries (10 ). // Retry up to 3 times
263- WithRetryStrategy (httpretrier .JitterBackoffStrategy ). // Use jitter backoff to avoid thundering herd
264- WithRetryBaseDelay (500 * time .Millisecond ). // Start with 500ms delay (httpretrier default)
265- WithRetryMaxDelay (10 * time .Second ). // Cap at 5 seconds
266- WithMaxIdleConns (10 ). // Max idle connections
267- WithMaxIdleConnsPerHost (10 ). // Max idle connections per host
268- WithIdleConnTimeout (90 * time .Second ). // Idle connection timeout
269- Build ()
270-
271- awsSCIM , err := aws .NewSCIMService (scimClient , cfg .AWSSCIMEndpoint , cfg .AWSSCIMAccessToken )
259+ // 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+ }
270+
271+ awsSCIM , err := aws .NewSCIMService (scimClient .StandardClient (), cfg .AWSSCIMEndpoint , cfg .AWSSCIMAccessToken )
272272 if err != nil {
273273 return nil , errors .Wrap (err , "cannot create aws scim service" )
274274 }
0 commit comments