Skip to content

Commit 9a6c318

Browse files
authored
Merge pull request #232 from splitio/FME-10102
[FME-10102] Update commons and initializationManager function
2 parents 68cec6b + 4abea69 commit 9a6c318

File tree

7 files changed

+42
-23
lines changed

7 files changed

+42
-23
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/splitio/go-client/v6
33
go 1.18
44

55
require (
6-
github.com/splitio/go-split-commons/v6 v6.1.1-0.20250918192536-25a68d9aef39
6+
github.com/splitio/go-split-commons/v6 v6.1.1-0.20250925190328-f22ee3e27850
77
github.com/splitio/go-toolkit/v5 v5.4.0
88

99
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
1818
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1919
github.com/redis/go-redis/v9 v9.0.4 h1:FC82T+CHJ/Q/PdyLW++GeCO+Ol59Y4T7R4jbgjvktgc=
2020
github.com/redis/go-redis/v9 v9.0.4/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk=
21-
github.com/splitio/go-split-commons/v6 v6.1.1-0.20250918192536-25a68d9aef39 h1:4ZncywIge5lCHbD3q+osxWPGGthzEbCOj6kDTVF7AoA=
22-
github.com/splitio/go-split-commons/v6 v6.1.1-0.20250918192536-25a68d9aef39/go.mod h1:cuW2HjbJJCVjlmmgJyoTs5UFxz8ET8vCgMUvZg1/EBg=
21+
github.com/splitio/go-split-commons/v6 v6.1.1-0.20250925190328-f22ee3e27850 h1:1HOSjfkE+mFSdYRmL5Cv34LzfgmHgBEdCKtr2d66wpQ=
22+
github.com/splitio/go-split-commons/v6 v6.1.1-0.20250925190328-f22ee3e27850/go.mod h1:cuW2HjbJJCVjlmmgJyoTs5UFxz8ET8vCgMUvZg1/EBg=
2323
github.com/splitio/go-toolkit/v5 v5.4.0 h1:g5WFpRhQomnXCmvfsNOWV4s5AuUrWIZ+amM68G8NBKM=
2424
github.com/splitio/go-toolkit/v5 v5.4.0/go.mod h1:xYhUvV1gga9/1029Wbp5pjnR6Cy8nvBpjw99wAbsMko=
2525
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=

splitio/client/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ func TestBlockUntilReadyInMemoryError(t *testing.T) {
971971
t.Error("It should return error")
972972
}
973973

974-
if err != nil && err.Error() != "SDK Initialization failed" {
974+
if err != nil && err.Error() != "SDK Initialization: time of 5 exceeded" {
975975
t.Error("Wrong error. Got: ", err.Error())
976976
}
977977
}

splitio/client/factory.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,9 @@ func (f *SplitFactory) IsReady() bool {
124124

125125
// initializates tasks for in-memory mode
126126
func (f *SplitFactory) initializationManager(readyChannel chan int, flagSetsInvalid int64) {
127-
go f.syncManager.Start()
128-
msg := <-readyChannel
129-
switch msg {
130-
case synchronizer.Ready:
131-
// Broadcast ready status for SDK
127+
go f.syncManager.StartBGSyng(readyChannel, f.cfg.Advanced.RetryEnabled, func() {
132128
f.broadcastReadiness(sdkStatusReady, make([]string, 0), flagSetsInvalid)
133-
default:
134-
f.broadcastReadiness(sdkInitializationFailed, make([]string, 0), flagSetsInvalid)
135-
}
129+
})
136130
}
137131

138132
func (f *SplitFactory) initializationRedis() {

splitio/client/input_validator_test.go

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,16 @@ func TestConsumerFactoryFlagSets(t *testing.T) {
666666

667667
func TestNotReadyYet(t *testing.T) {
668668
nonReadyUsages := 0
669-
logger := getMockedLogger()
669+
mLocal := MockWriter{}
670+
logger := logging.NewLogger(&logging.LoggerOptions{
671+
LogLevel: logging.LevelInfo,
672+
ErrorWriter: &mLocal,
673+
WarningWriter: &mLocal,
674+
InfoWriter: &mLocal,
675+
DebugWriter: nil,
676+
VerboseWriter: nil,
677+
})
678+
//logger := getMockedLogger()
670679
telemetryStorage := mocks.MockTelemetryStorage{
671680
RecordNonReadyUsageCall: func() {
672681
nonReadyUsages++
@@ -703,40 +712,54 @@ func TestNotReadyYet(t *testing.T) {
703712
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"
704713
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"
705714

715+
mLocal.Reset()
706716
clientNotReady.Treatment("test", "feature", nil)
707-
if !mW.Matches(strings.Replace(expectedMessage1, "{operation}", "Treatment", 1)) {
717+
if !mLocal.Matches(strings.Replace(expectedMessage1, "{operation}", "Treatment", 1)) {
708718
t.Error("Wrong message")
709719
}
710720

721+
mLocal.Reset()
711722
clientNotReady.Treatments("test", []string{"feature", "feature_2"}, nil)
712-
if !mW.Matches(strings.Replace(expectedMessage2, "{operation}", "Treatments", 1)) {
723+
if !mLocal.Matches(strings.Replace(expectedMessage2, "{operation}", "Treatments", 1)) {
713724
t.Error("Wrong message")
714725
}
715726

727+
mLocal.Reset()
716728
clientNotReady.TreatmentWithConfig("test", "feature", nil)
717-
if !mW.Matches(strings.Replace(expectedMessage1, "{operation}", "TreatmentWithConfig", 1)) {
729+
if !mLocal.Matches(strings.Replace(expectedMessage1, "{operation}", "TreatmentWithConfig", 1)) {
718730
t.Error("Wrong message")
719731
}
720732

733+
mLocal.Reset()
721734
clientNotReady.TreatmentsWithConfig("test", []string{"feature", "feature_2"}, nil)
722-
if !mW.Matches(strings.Replace(expectedMessage2, "{operation}", "TreatmentsWithConfig", 1)) {
723-
t.Error("Wrong message", mW.messages)
735+
if !mLocal.Matches(strings.Replace(expectedMessage2, "{operation}", "TreatmentsWithConfig", 1)) {
736+
t.Error("Wrong message", mLocal.messages)
724737
}
738+
739+
mLocal.Reset()
725740
expected := "Track: the SDK is not ready, results may be incorrect. Make sure to wait for SDK readiness before using this method"
726-
expectedTrack(clientNotReady.Track("key", "traffic", "eventType", nil, nil), expected, t)
727741

742+
clientNotReady.Track("key", "traffic", "eventType", nil, nil)
743+
if !mLocal.Matches(expected) {
744+
t.Error("Wrong message")
745+
}
746+
//expectedTrack(clientNotReady.Track("key", "traffic", "eventType", nil, nil), expected, t)
747+
748+
mLocal.Reset()
728749
maganerNotReady.Split("feature")
729-
if !mW.Matches(strings.Replace(expectedMessage, "{operation}", "Split", 1)) {
750+
if !mLocal.Matches(strings.Replace(expectedMessage, "{operation}", "Split", 1)) {
730751
t.Error("Wrong message")
731752
}
732753

754+
mLocal.Reset()
733755
maganerNotReady.Splits()
734-
if !mW.Matches(strings.Replace(expectedMessage, "{operation}", "Splits", 1)) {
756+
if !mLocal.Matches(strings.Replace(expectedMessage, "{operation}", "Splits", 1)) {
735757
t.Error("Wrong message")
736758
}
737759

760+
mLocal.Reset()
738761
maganerNotReady.SplitNames()
739-
if !mW.Matches(strings.Replace(expectedMessage, "{operation}", "SplitNames", 1)) {
762+
if !mLocal.Matches(strings.Replace(expectedMessage, "{operation}", "SplitNames", 1)) {
740763
t.Error("Wrong message")
741764
}
742765

splitio/conf/sdkconf.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ type AdvancedConfig struct {
107107
FlagSetsFilter []string
108108
FeatureFlagRules []string
109109
RuleBasedSegmentRules []string
110+
RetryEnabled bool
110111
}
111112

112113
// Default returns a config struct with all the default values
@@ -172,6 +173,7 @@ func Default() *SplitSdkConfig {
172173
StreamingEnabled: true,
173174
FeatureFlagRules: featureFlagsRules,
174175
RuleBasedSegmentRules: ruleBasedSegmentRules,
176+
RetryEnabled: true,
175177
},
176178
}
177179
}

splitio/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
package splitio
22

33
// Version contains a string with the split sdk version
4-
const Version = "6.7.0"
4+
const Version = "6.7.1-rc"

0 commit comments

Comments
 (0)