Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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.20250828184344-bcff10c58dfc
github.com/splitio/go-split-commons/v6 v6.1.1-0.20250912200801-1a8d4e3ca70b
github.com/splitio/go-toolkit/v5 v5.4.0

)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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.20250828184344-bcff10c58dfc h1:ZQyzjhZLdbDy9fnHzJ0I4I8aYRpq6DjVUx9uTe6So9U=
github.com/splitio/go-split-commons/v6 v6.1.1-0.20250828184344-bcff10c58dfc/go.mod h1:cuW2HjbJJCVjlmmgJyoTs5UFxz8ET8vCgMUvZg1/EBg=
github.com/splitio/go-split-commons/v6 v6.1.1-0.20250912200801-1a8d4e3ca70b h1:M/WRMUM2GZzZIymNbgrbW4PSN1zicZSdfK61MDXwlgo=
github.com/splitio/go-split-commons/v6 v6.1.1-0.20250912200801-1a8d4e3ca70b/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=
Expand Down
5 changes: 4 additions & 1 deletion splitio/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ func TestLocalhostMode(t *testing.T) {
t.Error(err)
}
client := factory.Client()
client.BlockUntilReady(1)
client.BlockUntilReady(100)

if factory.cfg.OperationMode != conf.Localhost {
t.Error("Localhost operation mode should be set when received apikey is 'localhost'")
Expand Down Expand Up @@ -1365,7 +1365,10 @@ func TestClient(t *testing.T) {
},
nil,
nil,
nil,
logger,
cfg.Advanced.FeatureFlagRules,
cfg.Advanced.RuleBasedSegmentRules,
)

mockedTelemetryStorage := mocks.MockTelemetryStorage{
Expand Down
12 changes: 9 additions & 3 deletions splitio/client/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/splitio/go-split-commons/v6/dtos"
"github.com/splitio/go-split-commons/v6/engine"
"github.com/splitio/go-split-commons/v6/engine/evaluator"
"github.com/splitio/go-split-commons/v6/engine/grammar"
"github.com/splitio/go-split-commons/v6/flagsets"
"github.com/splitio/go-split-commons/v6/healthcheck/application"
"github.com/splitio/go-split-commons/v6/provisional"
Expand Down Expand Up @@ -84,7 +85,7 @@ type SplitFactory struct {
func (f *SplitFactory) Client() *SplitClient {
return &SplitClient{
logger: f.logger,
evaluator: evaluator.NewEvaluator(f.storages.splits, f.storages.segments, f.storages.ruleBasedSegments, engine.NewEngine(f.logger), f.logger),
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),
impressions: f.storages.impressions,
events: f.storages.events,
validator: inputValidation{
Expand Down Expand Up @@ -300,8 +301,11 @@ func setupInMemoryFactory(
var dummyHC = &application.Dummy{}

splitAPI := api.NewSplitAPI(apikey, advanced, logger, metadata)

evaluator := evaluator.NewEvaluator(splitsStorage, segmentsStorage, ruleBasedSegmentStorage, nil, engine.NewEngine(logger), logger, cfg.Advanced.FeatureFlagRules, cfg.Advanced.RuleBasedSegmentRules)
ruleBuilder := grammar.NewRuleBuilder(segmentsStorage, ruleBasedSegmentStorage, nil, cfg.Advanced.FeatureFlagRules, cfg.Advanced.RuleBasedSegmentRules, logger, evaluator)
workers := synchronizer.Workers{
SplitUpdater: split.NewSplitUpdater(splitsStorage, ruleBasedSegmentStorage, splitAPI.SplitFetcher, logger, telemetryStorage, dummyHC, flagSetFilter),
SplitUpdater: split.NewSplitUpdater(splitsStorage, ruleBasedSegmentStorage, splitAPI.SplitFetcher, logger, telemetryStorage, dummyHC, flagSetFilter, ruleBuilder),
SegmentUpdater: segment.NewSegmentUpdater(splitsStorage, segmentsStorage, splitAPI.SegmentFetcher, logger, telemetryStorage, dummyHC),
EventRecorder: event.NewEventRecorderSingle(eventsStorage, splitAPI.EventRecorder, logger, metadata, telemetryStorage),
TelemetryRecorder: telemetry.NewTelemetrySynchronizer(telemetryStorage, splitAPI.TelemetryRecorder, splitsStorage, segmentsStorage, logger, metadata, telemetryStorage),
Expand Down Expand Up @@ -493,10 +497,12 @@ func setupLocalhostFactory(
QueueSize: cfg.Advanced.SegmentQueueSize,
SegmentDirectory: cfg.SegmentDirectory,
RefreshEnabled: cfg.LocalhostRefreshEnabled,
FfRulesAccepted: cfg.Advanced.FeatureFlagRules,
RbRulesAccepted: cfg.Advanced.RuleBasedSegmentRules,
}

syncManager, err := synchronizer.NewSynchronizerManager(
synchronizer.NewLocal(localConfig, splitAPI, splitStorage, segmentStorage, ruleBasedSegmentStorage, logger, telemetryStorage, dummyHC),
synchronizer.NewLocal(localConfig, splitAPI, splitStorage, segmentStorage, nil, ruleBasedSegmentStorage, logger, telemetryStorage, dummyHC),
logger,
config.AdvancedConfig{StreamingEnabled: false},
nil,
Expand Down
2 changes: 1 addition & 1 deletion splitio/client/input_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func TestValidatorOnDestroy(t *testing.T) {
logger := getMockedLogger()
localConfig := &synchronizer.LocalConfig{RefreshEnabled: false}
sync, _ := synchronizer.NewSynchronizerManager(
synchronizer.NewLocal(localConfig, &api.SplitAPI{}, mocks.MockSplitStorage{}, mocks.MockSegmentStorage{}, &mocks.MockRuleBasedSegmentStorage{}, logger, telemetryMockedStorage, &application.Dummy{}),
synchronizer.NewLocal(localConfig, &api.SplitAPI{}, mocks.MockSplitStorage{}, mocks.MockSegmentStorage{}, nil, &mocks.MockRuleBasedSegmentStorage{}, logger, telemetryMockedStorage, &application.Dummy{}),
logger,
commonsCfg.AdvancedConfig{},
authMocks.MockAuthClient{},
Expand Down
72 changes: 43 additions & 29 deletions splitio/conf/sdkconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

impressionlistener "github.com/splitio/go-client/v6/splitio/impressionListener"
"github.com/splitio/go-split-commons/v6/conf"
"github.com/splitio/go-split-commons/v6/engine/grammar"
"github.com/splitio/go-toolkit/v5/datastructures/set"
"github.com/splitio/go-toolkit/v5/logging"
"github.com/splitio/go-toolkit/v5/nethelpers"
Expand All @@ -25,6 +26,15 @@ const (
InMemoryStandAlone = "inmemory-standalone"
)

var featureFlagsRules = []string{grammar.MatcherTypeAllKeys, grammar.MatcherTypeInSegment, grammar.MatcherTypeWhitelist, grammar.MatcherTypeEqualTo, grammar.MatcherTypeGreaterThanOrEqualTo, grammar.MatcherTypeLessThanOrEqualTo, grammar.MatcherTypeBetween,
grammar.MatcherTypeEqualToSet, grammar.MatcherTypePartOfSet, grammar.MatcherTypeContainsAllOfSet, grammar.MatcherTypeContainsAnyOfSet, grammar.MatcherTypeStartsWith, grammar.MatcherTypeEndsWith, grammar.MatcherTypeContainsString, grammar.MatcherTypeInSplitTreatment,
grammar.MatcherTypeEqualToBoolean, grammar.MatcherTypeMatchesString, grammar.MatcherEqualToSemver, grammar.MatcherTypeGreaterThanOrEqualToSemver, grammar.MatcherTypeLessThanOrEqualToSemver, grammar.MatcherTypeBetweenSemver, grammar.MatcherTypeInListSemver,
grammar.MatcherTypeInRuleBasedSegment}
var ruleBasedSegmentRules = []string{grammar.MatcherTypeAllKeys, grammar.MatcherTypeInSegment, grammar.MatcherTypeWhitelist, grammar.MatcherTypeEqualTo, grammar.MatcherTypeGreaterThanOrEqualTo, grammar.MatcherTypeLessThanOrEqualTo, grammar.MatcherTypeBetween,
grammar.MatcherTypeEqualToSet, grammar.MatcherTypePartOfSet, grammar.MatcherTypeContainsAllOfSet, grammar.MatcherTypeContainsAnyOfSet, grammar.MatcherTypeStartsWith, grammar.MatcherTypeEndsWith, grammar.MatcherTypeContainsString,
grammar.MatcherTypeEqualToBoolean, grammar.MatcherTypeMatchesString, grammar.MatcherEqualToSemver, grammar.MatcherTypeGreaterThanOrEqualToSemver, grammar.MatcherTypeLessThanOrEqualToSemver, grammar.MatcherTypeBetweenSemver, grammar.MatcherTypeInListSemver,
grammar.MatcherTypeInRuleBasedSegment}

// SplitSdkConfig struct ...
// struct used to setup a Split.io SDK client.
//
Expand Down Expand Up @@ -80,21 +90,23 @@ type TaskPeriods struct {
// - SegmentQueueSize - How many segments can be queued for updating (should be >= # segments the user has)
// - SegmentWorkers - How many workers will be used when performing segments sync.
type AdvancedConfig struct {
ImpressionListener impressionlistener.ImpressionListener
HTTPTimeout int
SegmentQueueSize int
SegmentWorkers int
AuthServiceURL string
SdkURL string
EventsURL string
StreamingServiceURL string
TelemetryServiceURL string
EventsBulkSize int64
EventsQueueSize int
ImpressionsQueueSize int
ImpressionsBulkSize int64
StreamingEnabled bool
FlagSetsFilter []string
ImpressionListener impressionlistener.ImpressionListener
HTTPTimeout int
SegmentQueueSize int
SegmentWorkers int
AuthServiceURL string
SdkURL string
EventsURL string
StreamingServiceURL string
TelemetryServiceURL string
EventsBulkSize int64
EventsQueueSize int
ImpressionsQueueSize int
ImpressionsBulkSize int64
StreamingEnabled bool
FlagSetsFilter []string
FeatureFlagRules []string
RuleBasedSegmentRules []string
}

// Default returns a config struct with all the default values
Expand Down Expand Up @@ -144,20 +156,22 @@ func Default() *SplitSdkConfig {
EventsSync: defaultTaskPeriod,
},
Advanced: AdvancedConfig{
AuthServiceURL: "",
EventsURL: "",
SdkURL: "",
StreamingServiceURL: "",
TelemetryServiceURL: "",
HTTPTimeout: defaultHTTPTimeout,
ImpressionListener: nil,
SegmentQueueSize: 500,
SegmentWorkers: 10,
EventsBulkSize: 5000,
EventsQueueSize: 10000,
ImpressionsQueueSize: 10000,
ImpressionsBulkSize: 5000,
StreamingEnabled: true,
AuthServiceURL: "",
EventsURL: "",
SdkURL: "",
StreamingServiceURL: "",
TelemetryServiceURL: "",
HTTPTimeout: defaultHTTPTimeout,
ImpressionListener: nil,
SegmentQueueSize: 500,
SegmentWorkers: 10,
EventsBulkSize: 5000,
EventsQueueSize: 10000,
ImpressionsQueueSize: 10000,
ImpressionsBulkSize: 5000,
StreamingEnabled: true,
FeatureFlagRules: featureFlagsRules,
RuleBasedSegmentRules: ruleBasedSegmentRules,
},
}
}
Expand Down