Skip to content

Commit 9a1ac81

Browse files
committed
pr feedback
1 parent 044935f commit 9a1ac81

File tree

4 files changed

+11
-19
lines changed

4 files changed

+11
-19
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.0.3-0.20250107165105-06ac4432a361
6+
github.com/splitio/go-split-commons/v6 v6.0.3-0.20250110130515-1d29216e1be4
77
github.com/splitio/go-toolkit/v5 v5.4.0
88
)
99

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
1414
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1515
github.com/redis/go-redis/v9 v9.0.4 h1:FC82T+CHJ/Q/PdyLW++GeCO+Ol59Y4T7R4jbgjvktgc=
1616
github.com/redis/go-redis/v9 v9.0.4/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk=
17-
github.com/splitio/go-split-commons/v6 v6.0.3-0.20250106193848-789eab2683d9 h1:UvtXnoIddjx8KOgJ0GqAz/FL4UtkfNyfElM4rz04GgM=
18-
github.com/splitio/go-split-commons/v6 v6.0.3-0.20250106193848-789eab2683d9/go.mod h1:D/XIY/9Hmfk9ivWsRsJVp439kEdmHbzUi3PKzQQDOXY=
19-
github.com/splitio/go-split-commons/v6 v6.0.3-0.20250107165105-06ac4432a361 h1:VYLTOxshKSJEsJw77qpvRScPnG6/lARioZmfvHWKwsE=
20-
github.com/splitio/go-split-commons/v6 v6.0.3-0.20250107165105-06ac4432a361/go.mod h1:D/XIY/9Hmfk9ivWsRsJVp439kEdmHbzUi3PKzQQDOXY=
17+
github.com/splitio/go-split-commons/v6 v6.0.3-0.20250110130515-1d29216e1be4 h1:Y+WYCUZ9XNszNVSXBiqNi8IYQgaCZWkvhf10GW7cpII=
18+
github.com/splitio/go-split-commons/v6 v6.0.3-0.20250110130515-1d29216e1be4/go.mod h1:D/XIY/9Hmfk9ivWsRsJVp439kEdmHbzUi3PKzQQDOXY=
2119
github.com/splitio/go-toolkit/v5 v5.4.0 h1:g5WFpRhQomnXCmvfsNOWV4s5AuUrWIZ+amM68G8NBKM=
2220
github.com/splitio/go-toolkit/v5 v5.4.0/go.mod h1:xYhUvV1gga9/1029Wbp5pjnR6Cy8nvBpjw99wAbsMko=
2321
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=

splitio/client/client.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (c *SplitClient) getEvaluationsResult(matchingKey string, bucketingKey *str
9393
}
9494

9595
// createImpression creates impression to be stored and used by listener
96-
func (c *SplitClient) createImpression(featureFlag string, bucketingKey *string, evaluationLabel string, matchingKey string, treatment string, changeNumber int64) dtos.Impression {
96+
func (c *SplitClient) createImpression(featureFlag string, bucketingKey *string, evaluationLabel string, matchingKey string, treatment string, changeNumber int64, disabled bool) dtos.Impression {
9797
var label string
9898
if c.factory.cfg.LabelsEnabled {
9999
label = evaluationLabel
@@ -112,18 +112,12 @@ func (c *SplitClient) createImpression(featureFlag string, bucketingKey *string,
112112
Label: label,
113113
Treatment: treatment,
114114
Time: time.Now().UTC().UnixNano() / int64(time.Millisecond), // Convert standard timestamp to java's ms timestamps
115-
}
116-
}
117-
118-
func (c *SplitClient) createImpressionDecorated(featureFlag string, bucketingKey *string, matchingKey string, evaluationResult evaluator.Result) dtos.ImpressionDecorated {
119-
return dtos.ImpressionDecorated{
120-
Impression: c.createImpression(featureFlag, bucketingKey, evaluationResult.Label, matchingKey, evaluationResult.Treatment, evaluationResult.SplitChangeNumber),
121-
Disabled: evaluationResult.ImpressionsDisabled,
115+
Disabled: disabled,
122116
}
123117
}
124118

125119
// storeData stores impression, runs listener and stores metrics
126-
func (c *SplitClient) storeData(impressions []dtos.ImpressionDecorated, attributes map[string]interface{}, metricsLabel string, evaluationTime time.Duration) {
120+
func (c *SplitClient) storeData(impressions []dtos.Impression, attributes map[string]interface{}, metricsLabel string, evaluationTime time.Duration) {
127121
// Store impression
128122
if c.impressions != nil {
129123
listenerEnabled := c.impressionListener != nil
@@ -188,7 +182,7 @@ func (c *SplitClient) doTreatmentCall(key interface{}, featureFlag string, attri
188182
}
189183

190184
c.storeData(
191-
[]dtos.ImpressionDecorated{c.createImpressionDecorated(featureFlag, bucketingKey, matchingKey, *evaluationResult)},
185+
[]dtos.Impression{c.createImpression(featureFlag, bucketingKey, evaluationResult.Label, matchingKey, evaluationResult.Treatment, evaluationResult.SplitChangeNumber, evaluationResult.ImpressionsDisabled)},
192186
attributes,
193187
metricsLabel,
194188
evaluationResult.EvaluationTime,
@@ -229,7 +223,7 @@ func (c *SplitClient) generateControlTreatments(featureFlagNames []string, opera
229223
}
230224

231225
func (c *SplitClient) processResult(result evaluator.Results, operation string, bucketingKey *string, matchingKey string, attributes map[string]interface{}, metricsLabel string) (t map[string]TreatmentResult) {
232-
var bulkImpressions []dtos.ImpressionDecorated
226+
var bulkImpressions []dtos.Impression
233227
treatments := make(map[string]TreatmentResult)
234228
for feature, evaluation := range result.Evaluations {
235229
if !c.validator.IsSplitFound(evaluation.Label, feature, operation) {
@@ -238,7 +232,7 @@ func (c *SplitClient) processResult(result evaluator.Results, operation string,
238232
Config: nil,
239233
}
240234
} else {
241-
bulkImpressions = append(bulkImpressions, c.createImpressionDecorated(feature, bucketingKey, matchingKey, evaluation))
235+
bulkImpressions = append(bulkImpressions, c.createImpression(feature, bucketingKey, evaluation.Label, matchingKey, evaluation.Treatment, evaluation.SplitChangeNumber, evaluation.ImpressionsDisabled))
242236

243237
treatments[feature] = TreatmentResult{
244238
Treatment: evaluation.Treatment,

splitio/impressions/builder.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func BuildInMemoryManager(
5353
noneStrategy := strategy.NewNoneImpl(impressionsCounter, uniqueKeysTracker, listenerEnabled)
5454

5555
if cfg.ImpressionsMode == config.ImpressionsModeNone {
56-
impManager := provisional.NewImpressionManagerImp(noneStrategy, nil)
56+
impManager := provisional.NewImpressionManagerImp(noneStrategy, noneStrategy)
5757
return impManager, nil
5858
}
5959

@@ -102,7 +102,7 @@ func BuildRedisManager(
102102
noneStrategy := strategy.NewNoneImpl(impressionsCounter, uniqueKeysTracker, listenerEnabled)
103103

104104
if cfg.ImpressionsMode == config.ImpressionsModeNone {
105-
impManager := provisional.NewImpressionManagerImp(noneStrategy, nil)
105+
impManager := provisional.NewImpressionManagerImp(noneStrategy, noneStrategy)
106106
return impManager, nil
107107
}
108108

0 commit comments

Comments
 (0)