Skip to content

Commit

Permalink
Merge pull request #201 from splitio/task/commonsv5
Browse files Browse the repository at this point in the history
Task/commonsv5
  • Loading branch information
nmayorsplit authored Jul 18, 2023
2 parents 7ed870b + 4380cb0 commit b72bd9b
Show file tree
Hide file tree
Showing 68 changed files with 147 additions and 239,157 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
6.4.0 (Jul 18, 2023)
- Improved streaming architecture implementation to apply feature flag updates from the notification received which is now enhanced, improving efficiency and reliability of the whole update system.
- Pointed to new version of go-split-commons v5.0.0.

6.3.3 (Jun 9, 2023)
- Fixed buffering logic in impressions for consumer mode
- Pointed to new version of go-split-commons v4.3.5:
Expand Down
3 changes: 2 additions & 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/v4 v4.3.5
github.com/splitio/go-split-commons/v5 v5.0.0
github.com/splitio/go-toolkit/v5 v5.3.1
)

Expand All @@ -13,5 +13,6 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/redis/go-redis/v9 v9.0.4 // indirect
golang.org/x/sync v0.3.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
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/v4 v4.3.5 h1:APl589+rtk2Y864C0CkutJWtQkRciLFL+/hVTN86Ss0=
github.com/splitio/go-split-commons/v4 v4.3.5/go.mod h1:hj+ota77quCRuyK1cK8EOZANGDIlwCMBosF27I158S8=
github.com/splitio/go-split-commons/v5 v5.0.0 h1:bGRi0cf1JP5VNSi0a4BPQEWv/DACkeSKliazhPMVDPk=
github.com/splitio/go-split-commons/v5 v5.0.0/go.mod h1:lzoVmYJaCqB8UPSxWva0BZe7fF+bRJD+eP0rNi/lL7c=
github.com/splitio/go-toolkit/v5 v5.3.1 h1:9J/byd0fRxWj5/Zg0QZOnUxKBDIAMCGr7rySYzJKdJg=
github.com/splitio/go-toolkit/v5 v5.3.1/go.mod h1:xYhUvV1gga9/1029Wbp5pjnR6Cy8nvBpjw99wAbsMko=
github.com/twmb/murmur3 v1.1.6 h1:mqrRot1BRxm+Yct+vavLMou2/iJt0tNVTTC0QoIjaZg=
github.com/twmb/murmur3 v1.1.6/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
13 changes: 7 additions & 6 deletions splitio/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import (
"time"

"github.com/splitio/go-client/v6/splitio/conf"
"github.com/splitio/go-client/v6/splitio/engine/evaluator"
"github.com/splitio/go-client/v6/splitio/engine/evaluator/impressionlabels"
impressionlistener "github.com/splitio/go-client/v6/splitio/impressionListener"
"github.com/splitio/go-split-commons/v4/dtos"
"github.com/splitio/go-split-commons/v4/provisional"
"github.com/splitio/go-split-commons/v4/storage"
"github.com/splitio/go-split-commons/v4/telemetry"

"github.com/splitio/go-split-commons/v5/dtos"
"github.com/splitio/go-split-commons/v5/engine/evaluator"
"github.com/splitio/go-split-commons/v5/engine/evaluator/impressionlabels"
"github.com/splitio/go-split-commons/v5/provisional"
"github.com/splitio/go-split-commons/v5/storage"
"github.com/splitio/go-split-commons/v5/telemetry"
"github.com/splitio/go-toolkit/v5/logging"
)

Expand Down
100 changes: 79 additions & 21 deletions splitio/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,27 @@ import (

"github.com/splitio/go-client/v6/splitio"
"github.com/splitio/go-client/v6/splitio/conf"
"github.com/splitio/go-client/v6/splitio/engine/evaluator"
"github.com/splitio/go-client/v6/splitio/engine/evaluator/impressionlabels"
evaluatorMock "github.com/splitio/go-client/v6/splitio/engine/evaluator/mocks"
impressionlistener "github.com/splitio/go-client/v6/splitio/impressionListener"
commonsCfg "github.com/splitio/go-split-commons/v4/conf"
"github.com/splitio/go-split-commons/v4/dtos"
"github.com/splitio/go-split-commons/v4/healthcheck/application"
"github.com/splitio/go-split-commons/v4/provisional"
"github.com/splitio/go-split-commons/v4/provisional/strategy"
authMocks "github.com/splitio/go-split-commons/v4/service/mocks"
"github.com/splitio/go-split-commons/v4/storage"
"github.com/splitio/go-split-commons/v4/storage/inmemory"
"github.com/splitio/go-split-commons/v4/storage/inmemory/mutexqueue"
"github.com/splitio/go-split-commons/v4/storage/mocks"
"github.com/splitio/go-split-commons/v4/storage/redis"
"github.com/splitio/go-split-commons/v4/synchronizer"
syncMock "github.com/splitio/go-split-commons/v4/synchronizer/mocks"
"github.com/splitio/go-split-commons/v4/telemetry"
"github.com/splitio/go-split-commons/v4/util"

commonsCfg "github.com/splitio/go-split-commons/v5/conf"
"github.com/splitio/go-split-commons/v5/dtos"
"github.com/splitio/go-split-commons/v5/engine/evaluator"
"github.com/splitio/go-split-commons/v5/engine/evaluator/impressionlabels"
evaluatorMock "github.com/splitio/go-split-commons/v5/engine/evaluator/mocks"
"github.com/splitio/go-split-commons/v5/healthcheck/application"
"github.com/splitio/go-split-commons/v5/provisional"
"github.com/splitio/go-split-commons/v5/provisional/strategy"
authMocks "github.com/splitio/go-split-commons/v5/service/mocks"
"github.com/splitio/go-split-commons/v5/storage"
"github.com/splitio/go-split-commons/v5/storage/inmemory"
"github.com/splitio/go-split-commons/v5/storage/inmemory/mutexqueue"
"github.com/splitio/go-split-commons/v5/storage/mocks"
"github.com/splitio/go-split-commons/v5/storage/redis"
"github.com/splitio/go-split-commons/v5/synchronizer"
syncMock "github.com/splitio/go-split-commons/v5/synchronizer/mocks"
"github.com/splitio/go-split-commons/v5/telemetry"
"github.com/splitio/go-split-commons/v5/util"

"github.com/splitio/go-toolkit/v5/datastructures/set"
"github.com/splitio/go-toolkit/v5/logging"
predis "github.com/splitio/go-toolkit/v5/redis"
Expand Down Expand Up @@ -1945,7 +1947,7 @@ func TestTelemetryMemory(t *testing.T) {
time.Sleep(100 * time.Millisecond)
splitChanges := dtos.SplitChangesDTO{
Splits: []dtos.SplitDTO{
{Name: "split1", Killed: true, Status: "ACTIVE"},
{Name: "split1", Killed: true, Status: "ACTIVE", DefaultTreatment: "on"},
{Name: "split2", Killed: true, Status: "ACTIVE"},
{Name: "split3", Killed: true, Status: "INACTIVE"},
},
Expand Down Expand Up @@ -2003,20 +2005,29 @@ func TestTelemetryMemory(t *testing.T) {
if dataInPost.ActiveFactories != 1 {
t.Error("It should be 1")
}
if dataInPost.ImpressionsMode != telemetry.ImpressionsModeOptimized {
t.Error("It should be Optimized")
}
case 2:
if dataInPost.RedundantFactories != 1 {
t.Error("It should be 1")
}
if dataInPost.ActiveFactories != 1 {
t.Error("It should be 1")
}
if dataInPost.ImpressionsMode != telemetry.ImpressionsModeDebug {
t.Error("It should be Debug")
}
case 3:
if dataInPost.RedundantFactories != 1 {
t.Error("It should be 1")
}
if dataInPost.ActiveFactories != 2 {
t.Error("It should be 2")
}
if dataInPost.ImpressionsMode != telemetry.ImpressionsModeNone {
t.Error("It should be None")
}
}

if dataInPost.TimeUntilReady == 0 {
Expand Down Expand Up @@ -2044,6 +2055,42 @@ func TestTelemetryMemory(t *testing.T) {
if dataInPost.SessionLengthMs == 0 {
t.Error("It should record sessionsLength")
}
if dataInPost.UpdatesFromSSE.Splits != 0 {
t.Error("It should send ufs")
}

switch metricsStatsCalled {
case 1:
if dataInPost.ImpressionsQueued != 1 {
t.Error("It should queue one impression")
}
if dataInPost.ImpressionsDeduped != 1 {
t.Error("It should dedupe one impression")
}
if dataInPost.EventsQueued != 1 {
t.Error("It should queue one event")
}
case 2:
if dataInPost.ImpressionsQueued != 2 {
t.Error("It should queue 2 impressions")
}
if dataInPost.ImpressionsDeduped != 0 {
t.Error("It should not dedupe impressions")
}
if dataInPost.EventsQueued != 1 {
t.Error("It should queue one event")
}
case 3:
if dataInPost.ImpressionsQueued != 0 {
t.Error("It should not queue impressions")
}
if dataInPost.ImpressionsDeduped != 0 {
t.Error("It should not dedupe impressions")
}
if dataInPost.EventsQueued != 0 {
t.Error("It should not track event")
}
}
}

fmt.Fprintln(w, "ok")
Expand All @@ -2067,21 +2114,32 @@ func TestTelemetryMemory(t *testing.T) {
if len(manager.SplitNames()) != 2 {
t.Error("It should return splits")
}
client.Treatment("some", "split1", nil)
client.Treatment("some", "split1", nil)
client.Track("something", "something", "something", nil, nil)

sdkConf.ImpressionsMode = "debug"
factory2, _ := NewSplitFactory("something", sdkConf)
manager2 := factory2.Manager()
manager2.BlockUntilReady(1)
client2 := factory2.Client()
client2.BlockUntilReady(1)
if len(manager2.SplitNames()) != 2 {
t.Error("It should return splits")
}
client2.Treatment("some", "split1", nil)
client2.Treatment("some", "split1", nil)
client2.Track("something", "something", "something", nil, nil)

sdkConf.ImpressionsMode = "none"
factory3, _ := NewSplitFactory("something2", sdkConf)
manager3 := factory3.Manager()
manager3.BlockUntilReady(1)
client3 := factory3.Client()
client3.BlockUntilReady(1)
if len(manager3.SplitNames()) != 2 {
t.Error("It should return splits")
}
client3.Treatment("some", "split1", nil)
client3.Treatment("some", "split1", nil)

factory.Destroy()
factory2.Destroy()
Expand Down
59 changes: 29 additions & 30 deletions splitio/client/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,32 @@ import (

"github.com/splitio/go-client/v6/splitio"
"github.com/splitio/go-client/v6/splitio/conf"
"github.com/splitio/go-client/v6/splitio/engine"
"github.com/splitio/go-client/v6/splitio/engine/evaluator"
impressionlistener "github.com/splitio/go-client/v6/splitio/impressionListener"
config "github.com/splitio/go-split-commons/v4/conf"
"github.com/splitio/go-split-commons/v4/dtos"
"github.com/splitio/go-split-commons/v4/healthcheck/application"
"github.com/splitio/go-split-commons/v4/provisional"
"github.com/splitio/go-split-commons/v4/provisional/strategy"
"github.com/splitio/go-split-commons/v4/service/api"
"github.com/splitio/go-split-commons/v4/service/local"
"github.com/splitio/go-split-commons/v4/storage"
"github.com/splitio/go-split-commons/v4/storage/filter"
"github.com/splitio/go-split-commons/v4/storage/inmemory"
"github.com/splitio/go-split-commons/v4/storage/inmemory/mutexmap"
"github.com/splitio/go-split-commons/v4/storage/inmemory/mutexqueue"
"github.com/splitio/go-split-commons/v4/storage/mocks"
"github.com/splitio/go-split-commons/v4/storage/redis"
"github.com/splitio/go-split-commons/v4/synchronizer"
"github.com/splitio/go-split-commons/v4/synchronizer/worker/event"
"github.com/splitio/go-split-commons/v4/synchronizer/worker/impression"
"github.com/splitio/go-split-commons/v4/synchronizer/worker/impressionscount"
"github.com/splitio/go-split-commons/v4/synchronizer/worker/segment"
"github.com/splitio/go-split-commons/v4/synchronizer/worker/split"
"github.com/splitio/go-split-commons/v4/tasks"
"github.com/splitio/go-split-commons/v4/telemetry"

config "github.com/splitio/go-split-commons/v5/conf"
"github.com/splitio/go-split-commons/v5/dtos"
"github.com/splitio/go-split-commons/v5/engine"
"github.com/splitio/go-split-commons/v5/engine/evaluator"
"github.com/splitio/go-split-commons/v5/healthcheck/application"
"github.com/splitio/go-split-commons/v5/provisional"
"github.com/splitio/go-split-commons/v5/provisional/strategy"
"github.com/splitio/go-split-commons/v5/service/api"
"github.com/splitio/go-split-commons/v5/service/local"
"github.com/splitio/go-split-commons/v5/storage"
"github.com/splitio/go-split-commons/v5/storage/filter"
"github.com/splitio/go-split-commons/v5/storage/inmemory"
"github.com/splitio/go-split-commons/v5/storage/inmemory/mutexmap"
"github.com/splitio/go-split-commons/v5/storage/inmemory/mutexqueue"
"github.com/splitio/go-split-commons/v5/storage/mocks"
"github.com/splitio/go-split-commons/v5/storage/redis"
"github.com/splitio/go-split-commons/v5/synchronizer"
"github.com/splitio/go-split-commons/v5/synchronizer/worker/event"
"github.com/splitio/go-split-commons/v5/synchronizer/worker/impression"
"github.com/splitio/go-split-commons/v5/synchronizer/worker/impressionscount"
"github.com/splitio/go-split-commons/v5/synchronizer/worker/segment"
"github.com/splitio/go-split-commons/v5/synchronizer/worker/split"
"github.com/splitio/go-split-commons/v5/tasks"
"github.com/splitio/go-split-commons/v5/telemetry"
"github.com/splitio/go-toolkit/v5/logging"
)

Expand Down Expand Up @@ -301,14 +302,14 @@ func setupInMemoryFactory(

splitAPI := api.NewSplitAPI(apikey, advanced, logger, metadata)
workers := synchronizer.Workers{
SplitFetcher: split.NewSplitFetcher(splitsStorage, splitAPI.SplitFetcher, logger, telemetryStorage, dummyHC),
SegmentFetcher: segment.NewSegmentFetcher(splitsStorage, segmentsStorage, splitAPI.SegmentFetcher, logger, telemetryStorage, dummyHC),
SplitUpdater: split.NewSplitUpdater(splitsStorage, splitAPI.SplitFetcher, logger, telemetryStorage, dummyHC),
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),
}
splitTasks := synchronizer.SplitTasks{
SplitSyncTask: tasks.NewFetchSplitsTask(workers.SplitFetcher, cfg.TaskPeriods.SplitSync, logger),
SegmentSyncTask: tasks.NewFetchSegmentsTask(workers.SegmentFetcher, cfg.TaskPeriods.SegmentSync, advanced.SegmentWorkers, advanced.SegmentQueueSize, logger),
SplitSyncTask: tasks.NewFetchSplitsTask(workers.SplitUpdater, cfg.TaskPeriods.SplitSync, logger),
SegmentSyncTask: tasks.NewFetchSegmentsTask(workers.SegmentUpdater, cfg.TaskPeriods.SegmentSync, advanced.SegmentWorkers, advanced.SegmentQueueSize, logger),
EventSyncTask: tasks.NewRecordEventsTask(workers.EventRecorder, advanced.EventsBulkSize, cfg.TaskPeriods.EventsSync, logger),
TelemetrySyncTask: tasks.NewRecordTelemetryTask(workers.TelemetryRecorder, cfg.TaskPeriods.TelemetrySync, logger),
}
Expand Down Expand Up @@ -339,7 +340,6 @@ func setupInMemoryFactory(
workers,
logger,
inMememoryFullQueue,
dummyHC,
)

readyChannel := make(chan int, 1)
Expand Down Expand Up @@ -427,7 +427,6 @@ func setupRedisFactory(apikey string, cfg *conf.SplitSdkConfig, logger logging.L
workers,
logger,
inMememoryFullQueue,
nil,
)

syncManager := synchronizer.NewSynchronizerManagerRedis(syncImpl, logger)
Expand Down
4 changes: 2 additions & 2 deletions splitio/client/input_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"strconv"
"strings"

"github.com/splitio/go-client/v6/splitio/engine/evaluator/impressionlabels"
"github.com/splitio/go-split-commons/v4/storage"
"github.com/splitio/go-split-commons/v5/engine/evaluator/impressionlabels"
"github.com/splitio/go-split-commons/v5/storage"
"github.com/splitio/go-toolkit/v5/datastructures/set"
"github.com/splitio/go-toolkit/v5/logging"
)
Expand Down
22 changes: 11 additions & 11 deletions splitio/client/input_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import (
"time"

"github.com/splitio/go-client/v6/splitio/conf"
spConf "github.com/splitio/go-split-commons/v4/conf"
"github.com/splitio/go-split-commons/v4/dtos"
"github.com/splitio/go-split-commons/v4/healthcheck/application"
"github.com/splitio/go-split-commons/v4/provisional"
"github.com/splitio/go-split-commons/v4/provisional/strategy"
"github.com/splitio/go-split-commons/v4/service/api"
authMocks "github.com/splitio/go-split-commons/v4/service/mocks"
"github.com/splitio/go-split-commons/v4/storage/inmemory/mutexmap"
"github.com/splitio/go-split-commons/v4/storage/inmemory/mutexqueue"
"github.com/splitio/go-split-commons/v4/storage/mocks"
"github.com/splitio/go-split-commons/v4/synchronizer"
spConf "github.com/splitio/go-split-commons/v5/conf"
"github.com/splitio/go-split-commons/v5/dtos"
"github.com/splitio/go-split-commons/v5/healthcheck/application"
"github.com/splitio/go-split-commons/v5/provisional"
"github.com/splitio/go-split-commons/v5/provisional/strategy"
"github.com/splitio/go-split-commons/v5/service/api"
authMocks "github.com/splitio/go-split-commons/v5/service/mocks"
"github.com/splitio/go-split-commons/v5/storage/inmemory/mutexmap"
"github.com/splitio/go-split-commons/v5/storage/inmemory/mutexqueue"
"github.com/splitio/go-split-commons/v5/storage/mocks"
"github.com/splitio/go-split-commons/v5/synchronizer"
"github.com/splitio/go-toolkit/v5/logging"
)

Expand Down
4 changes: 2 additions & 2 deletions splitio/client/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package client
import (
"fmt"

"github.com/splitio/go-split-commons/v4/dtos"
"github.com/splitio/go-split-commons/v4/storage"
"github.com/splitio/go-split-commons/v5/dtos"
"github.com/splitio/go-split-commons/v5/storage"
"github.com/splitio/go-toolkit/v5/logging"
)

Expand Down
4 changes: 2 additions & 2 deletions splitio/client/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package client
import (
"testing"

"github.com/splitio/go-split-commons/v4/dtos"
"github.com/splitio/go-split-commons/v4/storage/inmemory/mutexmap"
"github.com/splitio/go-split-commons/v5/dtos"
"github.com/splitio/go-split-commons/v5/storage/inmemory/mutexmap"
"github.com/splitio/go-toolkit/v5/datastructures/set"
"github.com/splitio/go-toolkit/v5/logging"
)
Expand Down
2 changes: 1 addition & 1 deletion splitio/conf/sdkconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"

impressionlistener "github.com/splitio/go-client/v6/splitio/impressionListener"
"github.com/splitio/go-split-commons/v4/conf"
"github.com/splitio/go-split-commons/v5/conf"
"github.com/splitio/go-toolkit/v5/datastructures/set"
"github.com/splitio/go-toolkit/v5/logging"
"github.com/splitio/go-toolkit/v5/nethelpers"
Expand Down
2 changes: 1 addition & 1 deletion splitio/conf/sdkconf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package conf
import (
"testing"

"github.com/splitio/go-split-commons/v4/conf"
"github.com/splitio/go-split-commons/v5/conf"
)

func TestSdkConfNormalization(t *testing.T) {
Expand Down
Loading

0 comments on commit b72bd9b

Please sign in to comment.