Skip to content

Commit 794fee4

Browse files
authored
Merge pull request #1 from FeatureProbe/demo
chore: update demo code
2 parents 18cfe74 + d025eca commit 794fee4

File tree

1 file changed

+15
-27
lines changed

1 file changed

+15
-27
lines changed

src/main/java/com/featureprobe/sdk/example/FeatureProbeDemo.java

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,32 @@
1212
public class FeatureProbeDemo {
1313

1414
private static final FPConfig config = FPConfig.builder()
15-
.remoteUri("http://127.0.0.1:4007")
15+
.remoteUri("http://localhost:4007")
1616
.pollingMode(Duration.ofSeconds(3))
1717
.useMemoryRepository()
1818
.build();
1919

2020
private static final FeatureProbe fpClient =
21-
new FeatureProbe("server-61db54ecea79824cae3ac38d73f1961d698d0477", config);
21+
new FeatureProbe("server-8ed48815ef044428826787e9a238b9c6a479f98c", config);
2222

2323
public static void main(String[] args) {
2424

25-
FPUser user = new FPUser("user_unique");
26-
user.with("userId", "122121211212");
27-
user.with("tel", "12345678998");
25+
FPUser user = new FPUser("user_id");
26+
user.with("city", "New York");
2827

29-
boolean boolValue = fpClient.boolValue("bool_toggle_key", user, false);
30-
System.out.println("FeatureProbe evaluation boolean type toggle result is :" + boolValue);
31-
FPDetail<Boolean> boolDetail = fpClient.boolDetail("bool_toggle_key", user, false);
32-
System.out.println("FeatureProbe evaluation boolean type toggle result detail is :" + boolDetail.toString());
28+
double discount = fpClient.numberValue("commodity_spike_activity", user, 0);
29+
System.out.println("user1 discount is :" + discount);
30+
FPDetail<Double> detail = fpClient.numberDetail("commodity_spike_activity", user, 0);
31+
System.out.println("detail:" + detail.getReason());
3332

34-
String stringValue = fpClient.stringValue("string_toggle_key", user, "default");
35-
System.out.println("FeatureProbe evaluation string type toggle result is :" + stringValue);
36-
FPDetail<String> stringDetail = fpClient.stringDetail("string_toggle_key", user, "default");
37-
System.out.println("FeatureProbe evaluation string type toggle result detail is :" + stringDetail.toString());
38-
39-
40-
double numberValue = fpClient.numberValue("number_toggle_key", user, 0);
41-
System.out.println("FeatureProbe evaluation number type toggle result is :" + numberValue);
42-
FPDetail<Double> numberDetail = fpClient.numberDetail("number_toggle_key", user, 0);
43-
System.out.println("FeatureProbe evaluation number type toggle result detail is :" + numberDetail.toString());
44-
45-
46-
Map<String, String> defaultJson = new HashMap<>();
47-
defaultJson.put("name", "FeatureProbe");
48-
Map<String, String> jsonValue = fpClient.jsonValue("json_toggle_key", user, defaultJson, Map.class);
49-
System.out.println("FeatureProbe evaluation json type toggle result is :" + jsonValue);
50-
FPDetail<Map> jsonDetail = fpClient.jsonDetail("json_toggle_key", user, defaultJson, Map.class);
51-
System.out.println("FeatureProbe evaluation json type toggle result detail is :" + jsonDetail.toString());
5233

34+
FPUser user2 = new FPUser("user_id2");
35+
user2.with("city", "Paris");
36+
discount = fpClient.numberValue("commodity_spike_activity", user2, 0);
37+
System.out.println("user2 discount is :" + discount);
38+
FPDetail<Double> detail2 = fpClient.numberDetail("commodity_spike_activity", user2, 0);
39+
System.out.println("detail2:" + detail2.getReason());
40+
System.out.println("rule index:" + detail2.getRuleIndex().get());
5341
}
5442

5543
}

0 commit comments

Comments
 (0)