3
3
import io .getunleash .DefaultUnleash ;
4
4
import io .getunleash .Unleash ;
5
5
import io .getunleash .UnleashContext ;
6
- import io .getunleash .event .UnleashSubscriber ;
7
- import io .getunleash .repository .FeatureToggleResponse ;
8
6
import io .getunleash .util .UnleashConfig ;
9
7
10
8
public class AdvancedConstraints {
@@ -15,38 +13,22 @@ public static void main(String[] args) throws InterruptedException {
15
13
.customHttpHeader (
16
14
"Authorization" ,
17
15
getOrElse ("UNLEASH_API_TOKEN" ,
18
- "default:default.a45fede67f99b17f67312c93e00f448340e7af4ace2b0de2650f5a99 " ))
19
- .unleashAPI (getOrElse ("UNLEASH_API_URL" , "http ://localhost:3063 /api" ))
16
+ "*:development.25a06b75248528f8ca93ce179dcdd141aedfb632231e0d21fd8ff349 " ))
17
+ .unleashAPI (getOrElse ("UNLEASH_API_URL" , "https ://app.unleash-hosted.com/demo /api" ))
20
18
.instanceId ("java-example" )
21
19
.synchronousFetchOnInitialisation (true )
22
- .sendMetricsInterval (30 )
23
- .subscriber (
24
- new UnleashSubscriber () {
25
- @ Override
26
- public void togglesFetched (
27
- FeatureToggleResponse toggleResponse ) {
28
- System .out .println (toggleResponse );
29
- System .out .println (
30
- toggleResponse
31
- .getToggleCollection ()
32
- .getFeatures ()
33
- .size ());
34
- }
35
- })
36
- .build ();
20
+ .sendMetricsInterval (30 ).build ();
21
+
37
22
Unleash unleash = new DefaultUnleash (config );
23
+ UnleashContext context = UnleashContext .builder ()
24
+ .addProperty ("semver" , "1.5.2" )
25
+ .build ();
26
+ UnleashContext smallerSemver = UnleashContext .builder ()
27
+ .addProperty ("semver" , "1.1.0" )
28
+ .build ();
38
29
while (true ) {
39
- Thread .sleep (2000 );
40
- UnleashContext context = UnleashContext .builder ()
41
- .addProperty ("semver" , "1.5.2" )
42
- .build ();
43
- System .out .println (
44
- unleash .isEnabled ("advanced.constraints" , context )); // expect this to be true
45
- UnleashContext smallerSemver = UnleashContext .builder ()
46
- .addProperty ("semver" , "1.1.0" )
47
- .build ();
48
- System .out .println (
49
- unleash .isEnabled ("advanced.constraints" , smallerSemver )); // expect this to be false
30
+ unleash .isEnabled ("advanced.constraints" , context ); // expect this to be true
31
+ unleash .isEnabled ("advanced.constraints" , smallerSemver ); // expect this to be false
50
32
}
51
33
}
52
34
0 commit comments