Skip to content

Commit 5e1e63c

Browse files
committed
feedback
1 parent d3f9360 commit 5e1e63c

File tree

3 files changed

+28
-17
lines changed

3 files changed

+28
-17
lines changed

client/src/main/java/io/split/client/SplitClientImpl.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@
99
import io.split.engine.evaluator.Evaluator;
1010
import io.split.engine.SDKReadinessGates;
1111
import io.split.engine.evaluator.EvaluatorImp;
12-
import io.split.inputValidation.*;
12+
import io.split.engine.evaluator.Labels;
13+
1314
import io.split.engine.metrics.Metrics;
1415
import io.split.grammar.Treatments;
16+
import io.split.inputValidation.EventsValidator;
17+
import io.split.inputValidation.InputValidationResult;
18+
import io.split.inputValidation.KeyValidator;
19+
import io.split.inputValidation.SplitNameValidator;
20+
import io.split.inputValidation.TrafficTypeValidator;
1521
import org.slf4j.Logger;
1622
import org.slf4j.LoggerFactory;
1723

@@ -31,7 +37,7 @@ public final class SplitClientImpl implements SplitClient {
3137
public static final SplitResult SPLIT_RESULT_CONTROL = new SplitResult(Treatments.CONTROL, null);
3238

3339
private static final String GET_TREATMENT_LABEL = "sdk.getTreatment";
34-
private static final String DEFINITION_NOT_FOUND = "definition not found";
40+
private static final String GET_TREATMENT_WITH_CONFIG_LABEL = "sdk.getTreatmentWithConfig";
3541

3642
private static final Logger _log = LoggerFactory.getLogger(SplitClientImpl.class);
3743

@@ -79,17 +85,17 @@ public String getTreatment(Key key, String split, Map<String, Object> attributes
7985

8086
@Override
8187
public SplitResult getTreatmentWithConfig(String key, String split) {
82-
return getTreatmentWithConfigInternal(GET_TREATMENT_LABEL, key, null, split, Collections.<String, Object>emptyMap(), "getTreatmentWithConfig");
88+
return getTreatmentWithConfigInternal(GET_TREATMENT_WITH_CONFIG_LABEL, key, null, split, Collections.<String, Object>emptyMap(), "getTreatmentWithConfig");
8389
}
8490

8591
@Override
8692
public SplitResult getTreatmentWithConfig(String key, String split, Map<String, Object> attributes) {
87-
return getTreatmentWithConfigInternal(GET_TREATMENT_LABEL, key, null, split, attributes, "getTreatmentWithConfig");
93+
return getTreatmentWithConfigInternal(GET_TREATMENT_WITH_CONFIG_LABEL, key, null, split, attributes, "getTreatmentWithConfig");
8894
}
8995

9096
@Override
9197
public SplitResult getTreatmentWithConfig(Key key, String split, Map<String, Object> attributes) {
92-
return getTreatmentWithConfigInternal(GET_TREATMENT_LABEL, key.matchingKey(), key.bucketingKey(), split, attributes, "getTreatmentWithConfig");
98+
return getTreatmentWithConfigInternal(GET_TREATMENT_WITH_CONFIG_LABEL, key.matchingKey(), key.bucketingKey(), split, attributes, "getTreatmentWithConfig");
9399
}
94100

95101
@Override
@@ -197,7 +203,7 @@ private SplitResult getTreatmentWithConfigInternal(String label, String matching
197203

198204
EvaluatorImp.TreatmentLabelAndChangeNumber result = _evaluator.evaluateFeature(matchingKey, bucketingKey, split, attributes);
199205

200-
if (result.treatment.equals(Treatments.CONTROL) && result.label.equals(DEFINITION_NOT_FOUND) && _gates.isSDKReadyNow()) {
206+
if (result.treatment.equals(Treatments.CONTROL) && result.label.equals(Labels.DEFINITION_NOT_FOUND) && _gates.isSDKReadyNow()) {
201207
_log.warn(
202208
"getTreatment: you passed \"" + split + "\" that does not exist in this environment, " +
203209
"please double check what Splits exist in the web console.");

client/src/main/java/io/split/engine/evaluator/EvaluatorImp.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
import static com.google.common.base.Preconditions.checkNotNull;
1616

1717
public class EvaluatorImp implements Evaluator {
18-
private static final String NOT_IN_SPLIT = "not in split";
19-
private static final String DEFAULT_RULE = "default rule";
20-
private static final String KILLED = "killed";
21-
private static final String DEFINITION_NOT_FOUND = "definition not found";
22-
private static final String EXCEPTION = "exception";
18+
2319

2420
private static final Logger _log = LoggerFactory.getLogger(EvaluatorImp.class);
2521

@@ -35,17 +31,17 @@ public TreatmentLabelAndChangeNumber evaluateFeature(String matchingKey, String
3531
ParsedSplit parsedSplit = _splitCache.get(split);
3632

3733
if (parsedSplit == null) {
38-
return new TreatmentLabelAndChangeNumber(Treatments.CONTROL, DEFINITION_NOT_FOUND);
34+
return new TreatmentLabelAndChangeNumber(Treatments.CONTROL, Labels.DEFINITION_NOT_FOUND);
3935
}
4036

4137
return getTreatment(matchingKey, bucketingKey, parsedSplit, attributes);
4238
}
4339
catch (ChangeNumberExceptionWrapper e) {
4440
_log.error("Evaluator Exception", e.wrappedException());
45-
return new EvaluatorImp.TreatmentLabelAndChangeNumber(Treatments.CONTROL, EXCEPTION, e.changeNumber());
41+
return new EvaluatorImp.TreatmentLabelAndChangeNumber(Treatments.CONTROL, Labels.EXCEPTION, e.changeNumber());
4642
} catch (Exception e) {
4743
_log.error("Evaluator Exception", e);
48-
return new EvaluatorImp.TreatmentLabelAndChangeNumber(Treatments.CONTROL, EXCEPTION);
44+
return new EvaluatorImp.TreatmentLabelAndChangeNumber(Treatments.CONTROL, Labels.EXCEPTION);
4945
}
5046
}
5147

@@ -61,7 +57,7 @@ private TreatmentLabelAndChangeNumber getTreatment(String matchingKey, String bu
6157
try {
6258
if (parsedSplit.killed()) {
6359
String config = parsedSplit.configurations() != null ? parsedSplit.configurations().get(parsedSplit.defaultTreatment()) : null;
64-
return new TreatmentLabelAndChangeNumber(parsedSplit.defaultTreatment(), KILLED, parsedSplit.changeNumber(), config);
60+
return new TreatmentLabelAndChangeNumber(parsedSplit.defaultTreatment(), Labels.KILLED, parsedSplit.changeNumber(), config);
6561
}
6662

6763
/*
@@ -85,7 +81,7 @@ private TreatmentLabelAndChangeNumber getTreatment(String matchingKey, String bu
8581
if (bucket > parsedSplit.trafficAllocation()) {
8682
// out of split
8783
String config = parsedSplit.configurations() != null ? parsedSplit.configurations().get(parsedSplit.defaultTreatment()) : null;
88-
return new TreatmentLabelAndChangeNumber(parsedSplit.defaultTreatment(), NOT_IN_SPLIT, parsedSplit.changeNumber(), config);
84+
return new TreatmentLabelAndChangeNumber(parsedSplit.defaultTreatment(), Labels.NOT_IN_SPLIT, parsedSplit.changeNumber(), config);
8985
}
9086

9187
}
@@ -100,7 +96,7 @@ private TreatmentLabelAndChangeNumber getTreatment(String matchingKey, String bu
10096
}
10197

10298
String config = parsedSplit.configurations() != null ? parsedSplit.configurations().get(parsedSplit.defaultTreatment()) : null;
103-
return new TreatmentLabelAndChangeNumber(parsedSplit.defaultTreatment(), DEFAULT_RULE, parsedSplit.changeNumber(), config);
99+
return new TreatmentLabelAndChangeNumber(parsedSplit.defaultTreatment(), Labels.DEFAULT_RULE, parsedSplit.changeNumber(), config);
104100
} catch (Exception e) {
105101
throw new ChangeNumberExceptionWrapper(e, parsedSplit.changeNumber());
106102
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package io.split.engine.evaluator;
2+
3+
public class Labels {
4+
public static final String NOT_IN_SPLIT = "not in split";
5+
public static final String DEFAULT_RULE = "default rule";
6+
public static final String KILLED = "killed";
7+
public static final String DEFINITION_NOT_FOUND = "definition not found";
8+
public static final String EXCEPTION = "exception";
9+
}

0 commit comments

Comments
 (0)