Skip to content

Commit 6b6828f

Browse files
committed
Updated go commons with large segment fix
1 parent bb0580a commit 6b6828f

File tree

6 files changed

+60
-37
lines changed

6 files changed

+60
-37
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.20250828184344-bcff10c58dfc
6+
github.com/splitio/go-split-commons/v6 v6.1.1-0.20250912200801-1a8d4e3ca70b
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.20250828184344-bcff10c58dfc h1:ZQyzjhZLdbDy9fnHzJ0I4I8aYRpq6DjVUx9uTe6So9U=
22-
github.com/splitio/go-split-commons/v6 v6.1.1-0.20250828184344-bcff10c58dfc/go.mod h1:cuW2HjbJJCVjlmmgJyoTs5UFxz8ET8vCgMUvZg1/EBg=
21+
github.com/splitio/go-split-commons/v6 v6.1.1-0.20250912200801-1a8d4e3ca70b h1:M/WRMUM2GZzZIymNbgrbW4PSN1zicZSdfK61MDXwlgo=
22+
github.com/splitio/go-split-commons/v6 v6.1.1-0.20250912200801-1a8d4e3ca70b/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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ func TestLocalhostMode(t *testing.T) {
402402
t.Error(err)
403403
}
404404
client := factory.Client()
405-
client.BlockUntilReady(1)
405+
client.BlockUntilReady(100)
406406

407407
if factory.cfg.OperationMode != conf.Localhost {
408408
t.Error("Localhost operation mode should be set when received apikey is 'localhost'")
@@ -1365,7 +1365,10 @@ func TestClient(t *testing.T) {
13651365
},
13661366
nil,
13671367
nil,
1368+
nil,
13681369
logger,
1370+
cfg.Advanced.FeatureFlagRules,
1371+
cfg.Advanced.RuleBasedSegmentRules,
13691372
)
13701373

13711374
mockedTelemetryStorage := mocks.MockTelemetryStorage{

splitio/client/factory.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/splitio/go-split-commons/v6/dtos"
2020
"github.com/splitio/go-split-commons/v6/engine"
2121
"github.com/splitio/go-split-commons/v6/engine/evaluator"
22+
"github.com/splitio/go-split-commons/v6/engine/grammar"
2223
"github.com/splitio/go-split-commons/v6/flagsets"
2324
"github.com/splitio/go-split-commons/v6/healthcheck/application"
2425
"github.com/splitio/go-split-commons/v6/provisional"
@@ -84,7 +85,7 @@ type SplitFactory struct {
8485
func (f *SplitFactory) Client() *SplitClient {
8586
return &SplitClient{
8687
logger: f.logger,
87-
evaluator: evaluator.NewEvaluator(f.storages.splits, f.storages.segments, f.storages.ruleBasedSegments, engine.NewEngine(f.logger), f.logger),
88+
evaluator: evaluator.NewEvaluator(f.storages.splits, f.storages.segments, f.storages.ruleBasedSegments, nil, engine.NewEngine(f.logger), f.logger, f.cfg.Advanced.FeatureFlagRules, f.cfg.Advanced.RuleBasedSegmentRules),
8889
impressions: f.storages.impressions,
8990
events: f.storages.events,
9091
validator: inputValidation{
@@ -300,8 +301,11 @@ func setupInMemoryFactory(
300301
var dummyHC = &application.Dummy{}
301302

302303
splitAPI := api.NewSplitAPI(apikey, advanced, logger, metadata)
304+
305+
evaluator := evaluator.NewEvaluator(splitsStorage, segmentsStorage, ruleBasedSegmentStorage, nil, engine.NewEngine(logger), logger, cfg.Advanced.FeatureFlagRules, cfg.Advanced.RuleBasedSegmentRules)
306+
ruleBuilder := grammar.NewRuleBuilder(segmentsStorage, ruleBasedSegmentStorage, nil, cfg.Advanced.FeatureFlagRules, cfg.Advanced.RuleBasedSegmentRules, logger, evaluator)
303307
workers := synchronizer.Workers{
304-
SplitUpdater: split.NewSplitUpdater(splitsStorage, ruleBasedSegmentStorage, splitAPI.SplitFetcher, logger, telemetryStorage, dummyHC, flagSetFilter),
308+
SplitUpdater: split.NewSplitUpdater(splitsStorage, ruleBasedSegmentStorage, splitAPI.SplitFetcher, logger, telemetryStorage, dummyHC, flagSetFilter, ruleBuilder),
305309
SegmentUpdater: segment.NewSegmentUpdater(splitsStorage, segmentsStorage, splitAPI.SegmentFetcher, logger, telemetryStorage, dummyHC),
306310
EventRecorder: event.NewEventRecorderSingle(eventsStorage, splitAPI.EventRecorder, logger, metadata, telemetryStorage),
307311
TelemetryRecorder: telemetry.NewTelemetrySynchronizer(telemetryStorage, splitAPI.TelemetryRecorder, splitsStorage, segmentsStorage, logger, metadata, telemetryStorage),
@@ -493,10 +497,12 @@ func setupLocalhostFactory(
493497
QueueSize: cfg.Advanced.SegmentQueueSize,
494498
SegmentDirectory: cfg.SegmentDirectory,
495499
RefreshEnabled: cfg.LocalhostRefreshEnabled,
500+
FfRulesAccepted: cfg.Advanced.FeatureFlagRules,
501+
RbRulesAccepted: cfg.Advanced.RuleBasedSegmentRules,
496502
}
497503

498504
syncManager, err := synchronizer.NewSynchronizerManager(
499-
synchronizer.NewLocal(localConfig, splitAPI, splitStorage, segmentStorage, ruleBasedSegmentStorage, logger, telemetryStorage, dummyHC),
505+
synchronizer.NewLocal(localConfig, splitAPI, splitStorage, segmentStorage, nil, ruleBasedSegmentStorage, logger, telemetryStorage, dummyHC),
500506
logger,
501507
config.AdvancedConfig{StreamingEnabled: false},
502508
nil,

splitio/client/input_validator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ func TestValidatorOnDestroy(t *testing.T) {
356356
logger := getMockedLogger()
357357
localConfig := &synchronizer.LocalConfig{RefreshEnabled: false}
358358
sync, _ := synchronizer.NewSynchronizerManager(
359-
synchronizer.NewLocal(localConfig, &api.SplitAPI{}, mocks.MockSplitStorage{}, mocks.MockSegmentStorage{}, &mocks.MockRuleBasedSegmentStorage{}, logger, telemetryMockedStorage, &application.Dummy{}),
359+
synchronizer.NewLocal(localConfig, &api.SplitAPI{}, mocks.MockSplitStorage{}, mocks.MockSegmentStorage{}, nil, &mocks.MockRuleBasedSegmentStorage{}, logger, telemetryMockedStorage, &application.Dummy{}),
360360
logger,
361361
commonsCfg.AdvancedConfig{},
362362
authMocks.MockAuthClient{},

splitio/conf/sdkconf.go

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
impressionlistener "github.com/splitio/go-client/v6/splitio/impressionListener"
1313
"github.com/splitio/go-split-commons/v6/conf"
14+
"github.com/splitio/go-split-commons/v6/engine/grammar"
1415
"github.com/splitio/go-toolkit/v5/datastructures/set"
1516
"github.com/splitio/go-toolkit/v5/logging"
1617
"github.com/splitio/go-toolkit/v5/nethelpers"
@@ -25,6 +26,15 @@ const (
2526
InMemoryStandAlone = "inmemory-standalone"
2627
)
2728

29+
var featureFlagsRules = []string{grammar.MatcherTypeAllKeys, grammar.MatcherTypeInSegment, grammar.MatcherTypeWhitelist, grammar.MatcherTypeEqualTo, grammar.MatcherTypeGreaterThanOrEqualTo, grammar.MatcherTypeLessThanOrEqualTo, grammar.MatcherTypeBetween,
30+
grammar.MatcherTypeEqualToSet, grammar.MatcherTypePartOfSet, grammar.MatcherTypeContainsAllOfSet, grammar.MatcherTypeContainsAnyOfSet, grammar.MatcherTypeStartsWith, grammar.MatcherTypeEndsWith, grammar.MatcherTypeContainsString, grammar.MatcherTypeInSplitTreatment,
31+
grammar.MatcherTypeEqualToBoolean, grammar.MatcherTypeMatchesString, grammar.MatcherEqualToSemver, grammar.MatcherTypeGreaterThanOrEqualToSemver, grammar.MatcherTypeLessThanOrEqualToSemver, grammar.MatcherTypeBetweenSemver, grammar.MatcherTypeInListSemver,
32+
grammar.MatcherTypeInRuleBasedSegment}
33+
var ruleBasedSegmentRules = []string{grammar.MatcherTypeAllKeys, grammar.MatcherTypeInSegment, grammar.MatcherTypeWhitelist, grammar.MatcherTypeEqualTo, grammar.MatcherTypeGreaterThanOrEqualTo, grammar.MatcherTypeLessThanOrEqualTo, grammar.MatcherTypeBetween,
34+
grammar.MatcherTypeEqualToSet, grammar.MatcherTypePartOfSet, grammar.MatcherTypeContainsAllOfSet, grammar.MatcherTypeContainsAnyOfSet, grammar.MatcherTypeStartsWith, grammar.MatcherTypeEndsWith, grammar.MatcherTypeContainsString,
35+
grammar.MatcherTypeEqualToBoolean, grammar.MatcherTypeMatchesString, grammar.MatcherEqualToSemver, grammar.MatcherTypeGreaterThanOrEqualToSemver, grammar.MatcherTypeLessThanOrEqualToSemver, grammar.MatcherTypeBetweenSemver, grammar.MatcherTypeInListSemver,
36+
grammar.MatcherTypeInRuleBasedSegment}
37+
2838
// SplitSdkConfig struct ...
2939
// struct used to setup a Split.io SDK client.
3040
//
@@ -80,21 +90,23 @@ type TaskPeriods struct {
8090
// - SegmentQueueSize - How many segments can be queued for updating (should be >= # segments the user has)
8191
// - SegmentWorkers - How many workers will be used when performing segments sync.
8292
type AdvancedConfig struct {
83-
ImpressionListener impressionlistener.ImpressionListener
84-
HTTPTimeout int
85-
SegmentQueueSize int
86-
SegmentWorkers int
87-
AuthServiceURL string
88-
SdkURL string
89-
EventsURL string
90-
StreamingServiceURL string
91-
TelemetryServiceURL string
92-
EventsBulkSize int64
93-
EventsQueueSize int
94-
ImpressionsQueueSize int
95-
ImpressionsBulkSize int64
96-
StreamingEnabled bool
97-
FlagSetsFilter []string
93+
ImpressionListener impressionlistener.ImpressionListener
94+
HTTPTimeout int
95+
SegmentQueueSize int
96+
SegmentWorkers int
97+
AuthServiceURL string
98+
SdkURL string
99+
EventsURL string
100+
StreamingServiceURL string
101+
TelemetryServiceURL string
102+
EventsBulkSize int64
103+
EventsQueueSize int
104+
ImpressionsQueueSize int
105+
ImpressionsBulkSize int64
106+
StreamingEnabled bool
107+
FlagSetsFilter []string
108+
FeatureFlagRules []string
109+
RuleBasedSegmentRules []string
98110
}
99111

100112
// Default returns a config struct with all the default values
@@ -144,20 +156,22 @@ func Default() *SplitSdkConfig {
144156
EventsSync: defaultTaskPeriod,
145157
},
146158
Advanced: AdvancedConfig{
147-
AuthServiceURL: "",
148-
EventsURL: "",
149-
SdkURL: "",
150-
StreamingServiceURL: "",
151-
TelemetryServiceURL: "",
152-
HTTPTimeout: defaultHTTPTimeout,
153-
ImpressionListener: nil,
154-
SegmentQueueSize: 500,
155-
SegmentWorkers: 10,
156-
EventsBulkSize: 5000,
157-
EventsQueueSize: 10000,
158-
ImpressionsQueueSize: 10000,
159-
ImpressionsBulkSize: 5000,
160-
StreamingEnabled: true,
159+
AuthServiceURL: "",
160+
EventsURL: "",
161+
SdkURL: "",
162+
StreamingServiceURL: "",
163+
TelemetryServiceURL: "",
164+
HTTPTimeout: defaultHTTPTimeout,
165+
ImpressionListener: nil,
166+
SegmentQueueSize: 500,
167+
SegmentWorkers: 10,
168+
EventsBulkSize: 5000,
169+
EventsQueueSize: 10000,
170+
ImpressionsQueueSize: 10000,
171+
ImpressionsBulkSize: 5000,
172+
StreamingEnabled: true,
173+
FeatureFlagRules: featureFlagsRules,
174+
RuleBasedSegmentRules: ruleBasedSegmentRules,
161175
},
162176
}
163177
}

0 commit comments

Comments
 (0)