Created
April 4, 2022 20:38
-
-
Save schroedermatt/4324d66bd7e2a1fd58161833693416ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Configure the client that connects to Unleash if unleash.enabled is "true" | |
| **/ | |
| @Bean | |
| @ConditionalOnProperty(value = "unleash.enabled", havingValue = "true") | |
| Unleash defaultUnleash() { | |
| UnleashConfig config = UnleashConfig.builder() | |
| .unleashAPI("<http://unleash-api.com>") | |
| .instanceId("asdf-123") | |
| .appName("unleash-demo") | |
| .environment("development") | |
| .fetchTogglesInterval(10) | |
| .subscriber(new Log4JSubscriber()) | |
| .build(); | |
| return new Unleash(config); | |
| } | |
| /** | |
| * If unleash.enabled is false, the above bean will not be created. | |
| * In this scenario, the FakeUnleash client will be injected into the | |
| * app context for use. This is helpful for local development. | |
| **/ | |
| @Bean | |
| @ConditionalOnMissingBean(Unleash.class) | |
| Unleash fakeUnleash() { | |
| return new FakeUnleash(config); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment