@@ -27,6 +27,8 @@ const (
2727 defaultHost = "localhost"
2828 defaultResolver = rpc
2929 defaultGracePeriod = 5
30+ defaultRetryBackoffMs = 1000
31+ defaultRetryBackoffMaxMs = 120000
3032 defaultFatalStatusCodes = ""
3133
3234 rpc ResolverType = "rpc"
@@ -69,6 +71,8 @@ type ProviderConfiguration struct {
6971 CustomSyncProviderUri string
7072 GrpcDialOptionsOverride []grpc.DialOption
7173 RetryGracePeriod int
74+ RetryBackoffMs int
75+ RetryBackoffMaxMs int
7276 FatalStatusCodes []string
7377
7478 log logr.Logger
@@ -212,12 +216,8 @@ func (cfg *ProviderConfiguration) updateFromEnvVar() {
212216 if targetUri := os .Getenv (flagdTargetUriEnvironmentVariableName ); targetUri != "" {
213217 cfg .TargetUri = targetUri
214218 }
215- if gracePeriod := os .Getenv (flagdGracePeriodVariableName ); gracePeriod != "" {
216- if seconds , err := strconv .Atoi (gracePeriod ); err == nil {
217- cfg .RetryGracePeriod = seconds
218- cfg .RetryGracePeriod = getIntFromEnvVarOrDefault (flagdGracePeriodVariableName , defaultGracePeriod , cfg .log )
219- }
220- }
219+
220+ cfg .RetryGracePeriod = getIntFromEnvVarOrDefault (flagdGracePeriodVariableName , defaultGracePeriod , cfg .log )
221221
222222 var fatalStatusCodes string
223223 if envVal := os .Getenv (flagdFatalStatusCodesVariableName ); envVal != "" {
@@ -431,6 +431,20 @@ func WithRetryGracePeriod(gracePeriod int) ProviderOption {
431431 }
432432}
433433
434+ // WithRetryBackoffMs sets the initial backoff duration (in milliseconds) for retrying failed connections
435+ func WithRetryBackoffMs (retryBackoffMs int ) ProviderOption {
436+ return func (p * ProviderConfiguration ) {
437+ p .RetryBackoffMs = retryBackoffMs
438+ }
439+ }
440+
441+ // WithRetryBackoffMaxMs sets the maximum backoff duration (in milliseconds) for retrying failed connections
442+ func WithRetryBackoffMaxMs (retryBackoffMaxMs int ) ProviderOption {
443+ return func (p * ProviderConfiguration ) {
444+ p .RetryBackoffMaxMs = retryBackoffMaxMs
445+ }
446+ }
447+
434448// WithFatalStatusCodes allows to set a list of gRPC status codes, which will cause streams to give up
435449// and put the provider in a PROVIDER_FATAL state
436450func WithFatalStatusCodes (fatalStatusCodes []string ) ProviderOption {
0 commit comments