diff --git a/go.mod b/go.mod index af15c88..983603c 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/splitio/go-client/v6 go 1.18 require ( - github.com/splitio/go-split-commons/v6 v6.1.1-0.20250918192536-25a68d9aef39 + github.com/splitio/go-split-commons/v6 v6.1.1-0.20250925190328-f22ee3e27850 github.com/splitio/go-toolkit/v5 v5.4.0 ) diff --git a/go.sum b/go.sum index 14c29ce..8b42174 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/redis/go-redis/v9 v9.0.4 h1:FC82T+CHJ/Q/PdyLW++GeCO+Ol59Y4T7R4jbgjvktgc= github.com/redis/go-redis/v9 v9.0.4/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk= -github.com/splitio/go-split-commons/v6 v6.1.1-0.20250918192536-25a68d9aef39 h1:4ZncywIge5lCHbD3q+osxWPGGthzEbCOj6kDTVF7AoA= -github.com/splitio/go-split-commons/v6 v6.1.1-0.20250918192536-25a68d9aef39/go.mod h1:cuW2HjbJJCVjlmmgJyoTs5UFxz8ET8vCgMUvZg1/EBg= +github.com/splitio/go-split-commons/v6 v6.1.1-0.20250925190328-f22ee3e27850 h1:1HOSjfkE+mFSdYRmL5Cv34LzfgmHgBEdCKtr2d66wpQ= +github.com/splitio/go-split-commons/v6 v6.1.1-0.20250925190328-f22ee3e27850/go.mod h1:cuW2HjbJJCVjlmmgJyoTs5UFxz8ET8vCgMUvZg1/EBg= github.com/splitio/go-toolkit/v5 v5.4.0 h1:g5WFpRhQomnXCmvfsNOWV4s5AuUrWIZ+amM68G8NBKM= github.com/splitio/go-toolkit/v5 v5.4.0/go.mod h1:xYhUvV1gga9/1029Wbp5pjnR6Cy8nvBpjw99wAbsMko= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= diff --git a/splitio/client/client_test.go b/splitio/client/client_test.go index 8809476..f346799 100644 --- a/splitio/client/client_test.go +++ b/splitio/client/client_test.go @@ -971,7 +971,7 @@ func TestBlockUntilReadyInMemoryError(t *testing.T) { t.Error("It should return error") } - if err != nil && err.Error() != "SDK Initialization failed" { + if err != nil && err.Error() != "SDK Initialization: time of 5 exceeded" { t.Error("Wrong error. Got: ", err.Error()) } } diff --git a/splitio/client/factory.go b/splitio/client/factory.go index 9d8329a..d2a3cab 100644 --- a/splitio/client/factory.go +++ b/splitio/client/factory.go @@ -124,15 +124,9 @@ func (f *SplitFactory) IsReady() bool { // initializates tasks for in-memory mode func (f *SplitFactory) initializationManager(readyChannel chan int, flagSetsInvalid int64) { - go f.syncManager.Start() - msg := <-readyChannel - switch msg { - case synchronizer.Ready: - // Broadcast ready status for SDK + go f.syncManager.StartBGSyng(readyChannel, f.cfg.Advanced.RetryEnabled, func() { f.broadcastReadiness(sdkStatusReady, make([]string, 0), flagSetsInvalid) - default: - f.broadcastReadiness(sdkInitializationFailed, make([]string, 0), flagSetsInvalid) - } + }) } func (f *SplitFactory) initializationRedis() { diff --git a/splitio/client/input_validator_test.go b/splitio/client/input_validator_test.go index 85fee13..2cc63f6 100644 --- a/splitio/client/input_validator_test.go +++ b/splitio/client/input_validator_test.go @@ -666,7 +666,16 @@ func TestConsumerFactoryFlagSets(t *testing.T) { func TestNotReadyYet(t *testing.T) { nonReadyUsages := 0 - logger := getMockedLogger() + mLocal := MockWriter{} + logger := logging.NewLogger(&logging.LoggerOptions{ + LogLevel: logging.LevelInfo, + ErrorWriter: &mLocal, + WarningWriter: &mLocal, + InfoWriter: &mLocal, + DebugWriter: nil, + VerboseWriter: nil, + }) + //logger := getMockedLogger() telemetryStorage := mocks.MockTelemetryStorage{ RecordNonReadyUsageCall: func() { nonReadyUsages++ @@ -703,40 +712,54 @@ func TestNotReadyYet(t *testing.T) { expectedMessage1 := "{operation}: the SDK is not ready, results may be incorrect for feature flag feature. Make sure to wait for SDK readiness before using this method" expectedMessage2 := "{operation}: the SDK is not ready, results may be incorrect for feature flags feature, feature_2. Make sure to wait for SDK readiness before using this method" + mLocal.Reset() clientNotReady.Treatment("test", "feature", nil) - if !mW.Matches(strings.Replace(expectedMessage1, "{operation}", "Treatment", 1)) { + if !mLocal.Matches(strings.Replace(expectedMessage1, "{operation}", "Treatment", 1)) { t.Error("Wrong message") } + mLocal.Reset() clientNotReady.Treatments("test", []string{"feature", "feature_2"}, nil) - if !mW.Matches(strings.Replace(expectedMessage2, "{operation}", "Treatments", 1)) { + if !mLocal.Matches(strings.Replace(expectedMessage2, "{operation}", "Treatments", 1)) { t.Error("Wrong message") } + mLocal.Reset() clientNotReady.TreatmentWithConfig("test", "feature", nil) - if !mW.Matches(strings.Replace(expectedMessage1, "{operation}", "TreatmentWithConfig", 1)) { + if !mLocal.Matches(strings.Replace(expectedMessage1, "{operation}", "TreatmentWithConfig", 1)) { t.Error("Wrong message") } + mLocal.Reset() clientNotReady.TreatmentsWithConfig("test", []string{"feature", "feature_2"}, nil) - if !mW.Matches(strings.Replace(expectedMessage2, "{operation}", "TreatmentsWithConfig", 1)) { - t.Error("Wrong message", mW.messages) + if !mLocal.Matches(strings.Replace(expectedMessage2, "{operation}", "TreatmentsWithConfig", 1)) { + t.Error("Wrong message", mLocal.messages) } + + mLocal.Reset() expected := "Track: the SDK is not ready, results may be incorrect. Make sure to wait for SDK readiness before using this method" - expectedTrack(clientNotReady.Track("key", "traffic", "eventType", nil, nil), expected, t) + clientNotReady.Track("key", "traffic", "eventType", nil, nil) + if !mLocal.Matches(expected) { + t.Error("Wrong message") + } + //expectedTrack(clientNotReady.Track("key", "traffic", "eventType", nil, nil), expected, t) + + mLocal.Reset() maganerNotReady.Split("feature") - if !mW.Matches(strings.Replace(expectedMessage, "{operation}", "Split", 1)) { + if !mLocal.Matches(strings.Replace(expectedMessage, "{operation}", "Split", 1)) { t.Error("Wrong message") } + mLocal.Reset() maganerNotReady.Splits() - if !mW.Matches(strings.Replace(expectedMessage, "{operation}", "Splits", 1)) { + if !mLocal.Matches(strings.Replace(expectedMessage, "{operation}", "Splits", 1)) { t.Error("Wrong message") } + mLocal.Reset() maganerNotReady.SplitNames() - if !mW.Matches(strings.Replace(expectedMessage, "{operation}", "SplitNames", 1)) { + if !mLocal.Matches(strings.Replace(expectedMessage, "{operation}", "SplitNames", 1)) { t.Error("Wrong message") } diff --git a/splitio/conf/sdkconf.go b/splitio/conf/sdkconf.go index 973e5c5..3b0e044 100644 --- a/splitio/conf/sdkconf.go +++ b/splitio/conf/sdkconf.go @@ -107,6 +107,7 @@ type AdvancedConfig struct { FlagSetsFilter []string FeatureFlagRules []string RuleBasedSegmentRules []string + RetryEnabled bool } // Default returns a config struct with all the default values @@ -172,6 +173,7 @@ func Default() *SplitSdkConfig { StreamingEnabled: true, FeatureFlagRules: featureFlagsRules, RuleBasedSegmentRules: ruleBasedSegmentRules, + RetryEnabled: true, }, } } diff --git a/splitio/version.go b/splitio/version.go index 7309a07..f36fc3f 100644 --- a/splitio/version.go +++ b/splitio/version.go @@ -1,4 +1,4 @@ package splitio // Version contains a string with the split sdk version -const Version = "6.7.0" +const Version = "6.7.1-rc"