Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
[submodule "providers/flagd/flagd-testbed"]
path = providers/flagd/flagd-testbed
url = https://github.com/open-feature/flagd-testbed.git
branch = v2.11.1
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test:

# call with TESTCONTAINERS_RYUK_DISABLED="true" to avoid problems with podman on Macs
e2e:
go clean -testcache && go list -f '{{.Dir}}/...' -m | xargs -I{} go test -timeout=1m -tags=e2e {}
go clean -testcache && go list -f '{{.Dir}}/...' -m | xargs -I{} go test -timeout=2m -tags=e2e {}

lint:
go install -v github.com/golangci/golangci-lint/cmd/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions providers/flagd/e2e/inprocess_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ func TestInProcessProviderE2E(t *testing.T) {
"./",
}

// Run tests with in-process specific tags - exclude connection/event issues we won't tackle
tags := "@in-process && ~@unixsocket && ~@metadata && ~@grace && ~@customCert && ~@reconnect && ~@contextEnrichment && ~@sync-payload && ~@events"
// Run tests with in-process specific tags
tags := "@in-process && ~@unixsocket && ~@metadata && ~@customCert && ~@contextEnrichment && ~@sync-payload"

if err := runner.RunGherkinTestsWithSubtests(t, featurePaths, tags); err != nil {
t.Fatalf("Gherkin tests failed: %v", err)
Expand Down
1 change: 0 additions & 1 deletion providers/flagd/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ require (
github.com/open-feature/flagd/core v0.12.1
github.com/open-feature/go-sdk v1.15.1
github.com/open-feature/go-sdk-contrib/tests/flagd v0.0.0
github.com/testcontainers/testcontainers-go v0.32.0
go.uber.org/mock v0.5.2
go.uber.org/zap v1.27.0
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b
Expand Down
26 changes: 22 additions & 4 deletions providers/flagd/pkg/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ package flagd
import (
"errors"
"fmt"
"os"
"strconv"
"strings"

"github.com/go-logr/logr"
"github.com/open-feature/flagd/core/pkg/sync"
"github.com/open-feature/go-sdk-contrib/providers/flagd/internal/cache"
"github.com/open-feature/go-sdk-contrib/providers/flagd/internal/logger"
"google.golang.org/grpc"
"os"
"strconv"
"strings"
)

type ResolverType string
Expand All @@ -26,6 +25,7 @@ const (
defaultCache = cache.LRUValue
defaultHost = "localhost"
defaultResolver = rpc
defaultGracePeriod = 5

rpc ResolverType = "rpc"
inProcess ResolverType = "in-process"
Expand All @@ -44,6 +44,7 @@ const (
flagdSourceSelectorEnvironmentVariableName = "FLAGD_SOURCE_SELECTOR"
flagdOfflinePathEnvironmentVariableName = "FLAGD_OFFLINE_FLAG_SOURCE_PATH"
flagdTargetUriEnvironmentVariableName = "FLAGD_TARGET_URI"
flagdGracePeriodVariableName = "FLAGD_RETRY_GRACE_PERIOD"
)

type ProviderConfiguration struct {
Expand All @@ -64,6 +65,7 @@ type ProviderConfiguration struct {
CustomSyncProvider sync.ISync
CustomSyncProviderUri string
GrpcDialOptionsOverride []grpc.DialOption
RetryGracePeriod int

log logr.Logger
}
Expand All @@ -77,6 +79,7 @@ func newDefaultConfiguration(log logr.Logger) *ProviderConfiguration {
MaxCacheSize: defaultMaxCacheSize,
Resolver: defaultResolver,
Tls: defaultTLS,
RetryGracePeriod: defaultGracePeriod,
}

p.updateFromEnvVar()
Expand Down Expand Up @@ -224,6 +227,14 @@ func (cfg *ProviderConfiguration) updateFromEnvVar() {
if targetUri := os.Getenv(flagdTargetUriEnvironmentVariableName); targetUri != "" {
cfg.TargetUri = targetUri
}
if gracePeriod := os.Getenv(flagdGracePeriodVariableName); gracePeriod != "" {
if seconds, err := strconv.Atoi(gracePeriod); err == nil {
cfg.RetryGracePeriod = seconds
} else {
// Handle parsing error
cfg.log.Error(err, fmt.Sprintf("invalid grace period '%s'", gracePeriod))
}
}

}

Expand Down Expand Up @@ -397,3 +408,10 @@ func WithGrpcDialOptionsOverride(grpcDialOptionsOverride []grpc.DialOption) Prov
p.GrpcDialOptionsOverride = grpcDialOptionsOverride
}
}

// WithRetryGracePeriod allows to set a time window for the transition from stale to error state
func WithRetryGracePeriod(gracePeriod int) ProviderOption {
return func(p *ProviderConfiguration) {
p.RetryGracePeriod = gracePeriod
}
}
1 change: 1 addition & 0 deletions providers/flagd/pkg/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func NewProvider(opts ...ProviderOption) (*Provider, error) {
CustomSyncProvider: provider.providerConfiguration.CustomSyncProvider,
CustomSyncProviderUri: provider.providerConfiguration.CustomSyncProviderUri,
GrpcDialOptionsOverride: provider.providerConfiguration.GrpcDialOptionsOverride,
RetryGracePeriod: provider.providerConfiguration.RetryGracePeriod,
})
} else {
service = process.NewInProcessService(process.Configuration{
Expand Down
Loading
Loading