Skip to content

Commit c6b0616

Browse files
committed
chore(example): Update examples to use most recently released client
1 parent b293e4d commit c6b0616

File tree

4 files changed

+24
-22
lines changed

4 files changed

+24
-22
lines changed

examples/cli-example/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ repositories {
1313
}
1414

1515
dependencies {
16-
implementation("io.getunleash:unleash-client-java:10.2.0")
16+
implementation("io.getunleash:unleash-client-java:11.1.0")
1717
implementation("ch.qos.logback:logback-classic:1.4.12")
1818
}

examples/cli-example/src/main/java/io/getunleash/example/AdvancedConstraints.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import io.getunleash.Unleash;
55
import io.getunleash.UnleashContext;
66
import io.getunleash.util.UnleashConfig;
7+
import io.getunleash.event.UnleashReady;
8+
import io.getunleash.event.ClientFeaturesResponse;
9+
import io.getunleash.event.UnleashSubscriber;
710

811
public class AdvancedConstraints {
912

@@ -17,6 +20,14 @@ public static void main(String[] args) throws InterruptedException {
1720
.unleashAPI(getOrElse("UNLEASH_API_URL", "https://app.unleash-hosted.com/demo/api"))
1821
.instanceId("java-example")
1922
.synchronousFetchOnInitialisation(true)
23+
.subscriber(new UnleashSubscriber() {
24+
public void onReady(UnleashReady ready) {
25+
System.out.println("Unleash is ready");
26+
}
27+
public void togglesFetched(ClientFeaturesResponse toggleResponse) {
28+
System.out.println("Fetch toggles with status: " + toggleResponse.getStatus());
29+
}
30+
})
2031
.sendMetricsInterval(30).build();
2132

2233
Unleash unleash = new DefaultUnleash(config);

examples/okhttp-example/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ repositories {
1212
}
1313

1414
dependencies {
15-
implementation("io.getunleash:unleash-client-java:8.2.0")
16-
implementation("com.squareup.okhttp3:okhttp:4.9.3")
15+
implementation("io.getunleash:unleash-client-java:11.1.0")
16+
implementation("com.squareup.okhttp3:okhttp:5.2.0")
1717
}

examples/okhttp-example/src/main/java/io/getunleash/example/UnleashOkHttp.java

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import io.getunleash.UnleashException;
77
import io.getunleash.event.UnleashReady;
88
import io.getunleash.event.UnleashSubscriber;
9-
import io.getunleash.repository.FeatureToggleResponse;
109
import io.getunleash.repository.OkHttpFeatureFetcher;
1110
import io.getunleash.util.UnleashConfig;
1211

@@ -15,26 +14,11 @@ public static void main(String[] args) throws InterruptedException {
1514

1615
UnleashConfig config = UnleashConfig.builder().appName("client-example.okhttp")
1716
.customHttpHeader("Authorization",
18-
"*:production.ZvzGdauVXYPyevrQVqnt8LSRHKuW")
19-
.unleashAPI("http://localhost:1500/api").instanceId("okhttp-example")
17+
getOrElse("UNLEASH_API_TOKEN",
18+
"*:development.25a06b75248528f8ca93ce179dcdd141aedfb632231e0d21fd8ff349"))
19+
.unleashAPI(getOrElse("UNLEASH_API_URL", "https://app.unleash-hosted.com/demo/api"))
2020
.unleashFeatureFetcherFactory(OkHttpFeatureFetcher::new)
2121
.fetchTogglesInterval(10)
22-
.subscriber(new UnleashSubscriber() {
23-
@Override
24-
public void onReady(UnleashReady unleashReady) {
25-
System.out.println("Ready");
26-
}
27-
28-
@Override
29-
public void togglesFetched(FeatureToggleResponse toggleResponse) {
30-
System.out.println("Fetched toggles. " + toggleResponse);
31-
}
32-
33-
@Override
34-
public void onError(UnleashException unleashException) {
35-
System.out.println("Failed " + unleashException);
36-
}
37-
})
3822
.synchronousFetchOnInitialisation(true)
3923
.build();
4024
Unleash unleash = new DefaultUnleash(config);
@@ -46,4 +30,11 @@ public void onError(UnleashException unleashException) {
4630
System.out.println(unleash.getVariant("my.feature"));
4731
}
4832
}
33+
public static String getOrElse(String key, String defaultValue) {
34+
String value = System.getenv(key);
35+
if (value == null) {
36+
return defaultValue;
37+
}
38+
return value;
39+
}
4940
}

0 commit comments

Comments
 (0)