|
12 | 12 | public class FeatureProbeDemo { |
13 | 13 |
|
14 | 14 | private static final FPConfig config = FPConfig.builder() |
15 | | - .remoteUri("http://127.0.0.1:4007") |
| 15 | + .remoteUri("http://localhost:4007") |
16 | 16 | .pollingMode(Duration.ofSeconds(3)) |
17 | 17 | .useMemoryRepository() |
18 | 18 | .build(); |
19 | 19 |
|
20 | 20 | private static final FeatureProbe fpClient = |
21 | | - new FeatureProbe("server-61db54ecea79824cae3ac38d73f1961d698d0477", config); |
| 21 | + new FeatureProbe("server-8ed48815ef044428826787e9a238b9c6a479f98c", config); |
22 | 22 |
|
23 | 23 | public static void main(String[] args) { |
24 | 24 |
|
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"); |
28 | 27 |
|
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()); |
33 | 32 |
|
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()); |
52 | 33 |
|
| 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()); |
53 | 41 | } |
54 | 42 |
|
55 | 43 | } |
0 commit comments