@@ -11,7 +11,6 @@ import (
1111 "os"
1212 "strconv"
1313 "strings"
14- "time"
1514)
1615
1716type ResolverType string
@@ -26,7 +25,7 @@ const (
2625 defaultCache = cache .LRUValue
2726 defaultHost = "localhost"
2827 defaultResolver = rpc
29- defaultGracePeriod = 5 * time . Second
28+ defaultGracePeriod = 5
3029
3130 rpc ResolverType = "rpc"
3231 inProcess ResolverType = "in-process"
@@ -45,7 +44,7 @@ const (
4544 flagdSourceSelectorEnvironmentVariableName = "FLAGD_SOURCE_SELECTOR"
4645 flagdOfflinePathEnvironmentVariableName = "FLAGD_OFFLINE_FLAG_SOURCE_PATH"
4746 flagdTargetUriEnvironmentVariableName = "FLAGD_TARGET_URI"
48- flagdGracePeriodVariableName = "FLAGD_GRACE_PERIOD "
47+ flagdGracePeriodVariableName = "FLAGD_RETRY_GRACE_PERIOD "
4948)
5049
5150type ProviderConfiguration struct {
@@ -66,7 +65,7 @@ type ProviderConfiguration struct {
6665 CustomSyncProvider sync.ISync
6766 CustomSyncProviderUri string
6867 GrpcDialOptionsOverride []grpc.DialOption
69- GracePeriod time. Duration
68+ RetryGracePeriod int
7069
7170 log logr.Logger
7271}
@@ -80,7 +79,7 @@ func newDefaultConfiguration(log logr.Logger) *ProviderConfiguration {
8079 MaxCacheSize : defaultMaxCacheSize ,
8180 Resolver : defaultResolver ,
8281 Tls : defaultTLS ,
83- GracePeriod : defaultGracePeriod ,
82+ RetryGracePeriod : defaultGracePeriod ,
8483 }
8584
8685 p .updateFromEnvVar ()
@@ -230,7 +229,7 @@ func (cfg *ProviderConfiguration) updateFromEnvVar() {
230229 }
231230 if gracePeriod := os .Getenv (flagdGracePeriodVariableName ); gracePeriod != "" {
232231 if seconds , err := strconv .Atoi (gracePeriod ); err == nil {
233- cfg .GracePeriod = time . Duration ( seconds ) * time . Second
232+ cfg .RetryGracePeriod = seconds
234233 } else {
235234 // Handle parsing error
236235 cfg .log .Error (err , fmt .Sprintf ("invalid grace period '%s'" , gracePeriod ))
@@ -410,9 +409,9 @@ func WithGrpcDialOptionsOverride(grpcDialOptionsOverride []grpc.DialOption) Prov
410409 }
411410}
412411
413- // WithGracePeriod allows to set a time window for the transition from stale to error state
414- func WithGracePeriod (gracePeriod time. Duration ) ProviderOption {
412+ // WithRetryGracePeriod allows to set a time window for the transition from stale to error state
413+ func WithRetryGracePeriod (gracePeriod int ) ProviderOption {
415414 return func (p * ProviderConfiguration ) {
416- p .GracePeriod = gracePeriod
415+ p .RetryGracePeriod = gracePeriod
417416 }
418417}
0 commit comments