@@ -46,30 +46,32 @@ func (f CompositeFeatureService) GetDecision(decisionContext FeatureDecisionCont
46
46
47
47
// Check if user is bucketed in feature experiment
48
48
if f .featureExperimentService != nil && len (feature .FeatureExperiments ) > 0 {
49
- // @TODO: add in a feature decision service that takes into account multiple experiments (via group mutex)
50
- experiment := feature .FeatureExperiments [0 ]
51
- experimentDecisionContext := ExperimentDecisionContext {
52
- Experiment : & experiment ,
53
- ProjectConfig : decisionContext .ProjectConfig ,
54
- }
55
-
56
- experimentDecision , err := f .featureExperimentService .GetDecision (experimentDecisionContext , userContext )
57
- // Variation not nil means we got a decision and should return it
58
- if experimentDecision .Variation != nil {
59
- featureDecision := FeatureDecision {
60
- Experiment : experiment ,
61
- Decision : experimentDecision .Decision ,
62
- Variation : experimentDecision .Variation ,
63
- Source : FeatureTest ,
49
+ // @TODO this can be improved by getting group ID first and determining experiment ID and then bucketing in experiment ID
50
+ for idx := 0 ; idx < len (feature .FeatureExperiments ); idx ++ {
51
+ experiment := feature .FeatureExperiments [idx ]
52
+ experimentDecisionContext := ExperimentDecisionContext {
53
+ Experiment : & experiment ,
54
+ ProjectConfig : decisionContext .ProjectConfig ,
64
55
}
65
56
66
- cfLogger .Debug (fmt .Sprintf (
67
- `Decision made for feature test with key "%s" for user "%s" with the following reason: "%s".` ,
68
- feature .Key ,
69
- userContext .ID ,
70
- featureDecision .Reason ,
71
- ))
72
- return featureDecision , err
57
+ experimentDecision , err := f .featureExperimentService .GetDecision (experimentDecisionContext , userContext )
58
+ // Variation not nil means we got a decision and should return it
59
+ if experimentDecision .Variation != nil {
60
+ featureDecision := FeatureDecision {
61
+ Experiment : experiment ,
62
+ Decision : experimentDecision .Decision ,
63
+ Variation : experimentDecision .Variation ,
64
+ Source : FeatureTest ,
65
+ }
66
+
67
+ cfLogger .Debug (fmt .Sprintf (
68
+ `Decision made for feature test with key "%s" for user "%s" with the following reason: "%s".` ,
69
+ feature .Key ,
70
+ userContext .ID ,
71
+ featureDecision .Reason ,
72
+ ))
73
+ return featureDecision , err
74
+ }
73
75
}
74
76
}
75
77
0 commit comments