Skip to content

Commit 1078bb2

Browse files
author
jianggang
committed
feat: example add featureprobe.io datasource
1 parent d32bd8a commit 1078bb2

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ After you install and import the SDK, create a single, shared instance of the Fe
6363
```java
6464
public class Demo {
6565
private static final FPConfig config = FPConfig.builder()
66-
.remoteUri("http://127.0.0.1:4007")
66+
// FeatureProbe server URL for local docker
67+
// .remoteUri("http://127.0.0.1:4007")
68+
// FeatureProbe server URL for featureprobe.io
69+
.eventUrl(new URL("https://featureprobe.io/api/server/events"))
70+
.synchronizerUrl(new URL("https://featureprobe.io/api/server/toggles"))
6771
.pollingMode(Duration.ofSeconds(3))
6872
.useMemoryRepository()
6973
.build();
@@ -80,7 +84,11 @@ You can use sdk to check which variation a particular user will receive for a gi
8084
```java
8185
public class Demo {
8286
private static final FPConfig config = FPConfig.builder()
83-
.remoteUri("http://127.0.0.1:4007")
87+
// FeatureProbe server URL for local docker
88+
// .remoteUri("http://127.0.0.1:4007")
89+
// FeatureProbe server URL for featureprobe.io
90+
.eventUrl(new URL("https://featureprobe.io/api/server/events"))
91+
.synchronizerUrl(new URL("https://featureprobe.io/api/server/toggles"))
8492
.pollingMode(Duration.ofSeconds(3))
8593
.useMemoryRepository()
8694
.build();

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,37 @@
44
import com.featureprobe.sdk.server.FPDetail;
55
import com.featureprobe.sdk.server.FPUser;
66
import com.featureprobe.sdk.server.FeatureProbe;
7+
8+
import java.net.MalformedURLException;
9+
import java.net.URL;
710
import java.time.Duration;
811
import org.slf4j.LoggerFactory;
912
import ch.qos.logback.classic.Level;
1013
import ch.qos.logback.classic.Logger;
1114

1215
public class FeatureProbeDemo {
1316

14-
// FeatureProbe server URL
15-
private static final String FEATURE_PROBE_SERVER_URL = "http://localhost:4007";
17+
// FeatureProbe server URL for local docker
18+
// private static final String FEATURE_PROBE_SERVER_URL = "http://localhost:4007";
19+
20+
// FeatureProbe server URL for featureprobe.io
21+
private static final String FEATURE_PROBE_IO_EVENT_URL = "https://featureprobe.io/api/server/events";
22+
private static final String FEATURE_PROBE_IO_synchronizer_URL = "https://featureprobe.io/api/server/toggles";
1623

1724
// Server Side SDK Key for your project and environment
1825
public static final String SERVER_SDK_KEY = "server-8ed48815ef044428826787e9a238b9c6a479f98c";
1926

2027
// Toggle you want to use
2128
public static final String TOGGLE_KEY = "promotion_activity";
2229

23-
public static void main(String[] args) {
30+
public static void main(String[] args) throws MalformedURLException {
2431
Logger root = (Logger)LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
2532
root.setLevel(Level.WARN);
2633

2734
final FPConfig config = FPConfig.builder()
28-
.remoteUri(FEATURE_PROBE_SERVER_URL)
35+
// .remoteUri(FEATURE_PROBE_SERVER_URL)
36+
.eventUrl(new URL(FEATURE_PROBE_IO_EVENT_URL))
37+
.synchronizerUrl(new URL(FEATURE_PROBE_IO_synchronizer_URL))
2938
.pollingMode(Duration.ofSeconds(3))
3039
.useMemoryRepository()
3140
.build();

0 commit comments

Comments
 (0)