Skip to content

Commit 4abea69

Browse files
committed
Added new config for retry
1 parent 8d0ff96 commit 4abea69

File tree

5 files changed

+38
-22
lines changed

5 files changed

+38
-22
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.20250924141339-b02fb5e5bd23
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.20250924141339-b02fb5e5bd23 h1:+XY4WtPOXFNwc4ZW3Q6ir7BvjxmGfwB+sRDanS4+BqQ=
22-
github.com/splitio/go-split-commons/v6 v6.1.1-0.20250924141339-b02fb5e5bd23/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/factory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ 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.StartBGSyng(readyChannel, true, func() {
127+
go f.syncManager.StartBGSyng(readyChannel, f.cfg.Advanced.RetryEnabled, func() {
128128
f.broadcastReadiness(sdkStatusReady, make([]string, 0), flagSetsInvalid)
129129
})
130130
}

splitio/client/input_validator_test.go

Lines changed: 32 additions & 18 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,49 +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

706-
mW.Reset()
715+
mLocal.Reset()
707716
clientNotReady.Treatment("test", "feature", nil)
708-
if !mW.Matches(strings.Replace(expectedMessage1, "{operation}", "Treatment", 1)) {
717+
if !mLocal.Matches(strings.Replace(expectedMessage1, "{operation}", "Treatment", 1)) {
709718
t.Error("Wrong message")
710719
}
711720

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

718-
mW.Reset()
727+
mLocal.Reset()
719728
clientNotReady.TreatmentWithConfig("test", "feature", nil)
720-
if !mW.Matches(strings.Replace(expectedMessage1, "{operation}", "TreatmentWithConfig", 1)) {
729+
if !mLocal.Matches(strings.Replace(expectedMessage1, "{operation}", "TreatmentWithConfig", 1)) {
721730
t.Error("Wrong message")
722731
}
723732

724-
mW.Reset()
733+
mLocal.Reset()
725734
clientNotReady.TreatmentsWithConfig("test", []string{"feature", "feature_2"}, nil)
726-
if !mW.Matches(strings.Replace(expectedMessage2, "{operation}", "TreatmentsWithConfig", 1)) {
727-
t.Error("Wrong message", mW.messages)
735+
if !mLocal.Matches(strings.Replace(expectedMessage2, "{operation}", "TreatmentsWithConfig", 1)) {
736+
t.Error("Wrong message", mLocal.messages)
728737
}
729738

730-
mW.Reset()
739+
mLocal.Reset()
731740
expected := "Track: the SDK is not ready, results may be incorrect. Make sure to wait for SDK readiness before using this method"
732-
expectedTrack(clientNotReady.Track("key", "traffic", "eventType", nil, nil), expected, t)
733741

734-
mW.Reset()
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()
735749
maganerNotReady.Split("feature")
736-
if !mW.Matches(strings.Replace(expectedMessage, "{operation}", "Split", 1)) {
750+
if !mLocal.Matches(strings.Replace(expectedMessage, "{operation}", "Split", 1)) {
737751
t.Error("Wrong message")
738752
}
739753

740-
mW.Reset()
754+
mLocal.Reset()
741755
maganerNotReady.Splits()
742-
if !mW.Matches(strings.Replace(expectedMessage, "{operation}", "Splits", 1)) {
756+
if !mLocal.Matches(strings.Replace(expectedMessage, "{operation}", "Splits", 1)) {
743757
t.Error("Wrong message")
744758
}
745759

746-
mW.Reset()
760+
mLocal.Reset()
747761
maganerNotReady.SplitNames()
748-
if !mW.Matches(strings.Replace(expectedMessage, "{operation}", "SplitNames", 1)) {
762+
if !mLocal.Matches(strings.Replace(expectedMessage, "{operation}", "SplitNames", 1)) {
749763
t.Error("Wrong message")
750764
}
751765

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
}

0 commit comments

Comments
 (0)