1111Client Java for working with Switcher-API.
1212https://github.com/switcherapi/switcher-api
1313
14- - Flexible and robust functions that will keep your code clean and maintainable.
14+ - Flexible and robust SDK that will keep your code clean and maintainable.
1515- Able to work offline using a snapshot file downloaded from your remote Switcher-API Domain.
16- - Silent mode is a hybrid configuration that automatically enables a contingent sub-process in case of any connectivity issue.
16+ - Silent mode is a hybrid configuration that automatically enables contingent sub-processes in case of any connectivity issue.
1717- Built-in mock implementation for clear and easy implementation of automated testing.
18- - Easy to setup. Switcher Context is responsible to manage all the complexity between your application and API.
18+ - Easy to setup. Switcher Context is responsible to manage all the configuration complexity between your application and API.
1919
2020# Usage
2121
@@ -26,13 +26,13 @@ https://github.com/switcherapi/switcher-api
2626<dependency >
2727 <groupId >com.github.switcherapi</groupId >
2828 <artifactId >switcher-client</artifactId >
29- <version >1.1 .0</version >
29+ <version >1.2 .0</version >
3030</dependency >
3131```
3232
3333## Context properties
3434#### Newest versions - v1.2.0
35- SwitcherContext is a toolkit that abstracts all external configurations regarding API access and SDK behaviors.
35+ SwitcherContext implements all external configurations regarding API access and SDK behaviors.
3636This new approach has eliminated unnecessary boilerplates and also has added a new layer for security purposes.
3737
3838Similarly as frameworks like Spring Boot, Log4j, the SDK also requires creating an external properties file that will contain all the settings.
@@ -42,18 +42,18 @@ Similarly as frameworks like Spring Boot, Log4j, the SDK also requires creating
4242
4343```
4444#required
45- switcher.context -> Your Feature class that extends SwitcherContext
46- switcher.url -> Endpoint of your Swither-API
47- switcher.apikey -> Switcher-API key generated for your application
48- switcher.component -> Application name
45+ switcher.context -> Feature class that extends SwitcherContext
46+ switcher.url -> Swither-API endpoint
47+ switcher.apikey -> Switcher-API key generated for the application/component
48+ switcher.component -> Application/component name
4949switcher.environment -> Environment name. Production environment is named as 'default'
5050switcher.domain -> Domain name
5151
5252#optional
5353switcher.offline -> true/false When offline, it will only use a local snapshot file
54- switcher.snapshot.file -> Snapshot file patch
55- switcher.snapshot.location -> Folder where snapshots will be saved/read
56- switcher.snapshot.auto -> true/false Lookup for snapshot when loading the application
54+ switcher.snapshot.file -> Snapshot file path
55+ switcher.snapshot.location -> Folder from where snapshots will be saved/read
56+ switcher.snapshot.auto -> true/false Automated lookup for snapshot when loading the application
5757switcher.silent -> true/false Contingency in case of some problem with connectivity with the API
5858switcher.retry -> Time given to the module to re-establish connectivity with the API - e.g. 5s (s: seconds - m: minutes - h: hours)
5959```
@@ -133,7 +133,9 @@ switcher.isItOn(entries);
1331333 . ** Strategy validation - chained call**
134134Create chained calls using 'getSwitcher' then 'prepareEntry' then 'isItOn' functions.
135135
136+
136137``` java
138+ @Deprecated
137139Switcher switcher = SwitcherFactory . getSwitcher(FEATURE01 )
138140 .prepareEntry(new Entry (Entry . VALUE , " My value" ))
139141 .prepareEntry(new Entry (Entry . NETWORK , " 10.0.0.1" ))
@@ -154,19 +156,34 @@ All-in-one method is fast and include everything you need to execute a complex c
154156
155157``` java
156158switcher. isItOn(FEATURE01 , new Entry (Entry . NETWORK , " 10.0.0.3" ), false );
159+ // or
160+ switcher. checkNetwork(" 10.0.0.3" ). isItOn(FEATURE01 );
157161```
158162
159163## Offline settings
160- You can also force the Switcher library to work offline. In this case, the snapshot location must be set up and the context re-built using the offline flag .
164+ You can also force the Switcher library to work offline. In this case, the snapshot location must be set up, so the context can be re-built using the offline configuration .
161165
162166``` java
167+ @Deprecated
163168properties. put(SwitcherContextParam . SNAPSHOT_LOCATION , " /src/resources" );
164169SwitcherFactory . buildContext(properties, true );
165170
166171Switcher switcher = MyAppFeatures . getSwitcher(FEATURE01 );
167172switcher. isItOn();
168173```
169174
175+ When using version 1.2.0 or greater, it also can be done as following:
176+
177+ ``` java
178+ MyAppFeatures . getProperties(). setOfflineMode(true );
179+ MyAppFeatures . getProperties(). setSnapshotLocation(" /src/resources" );
180+ MyAppFeatures . initializeClient();
181+
182+ Switcher switcher = MyAppFeatures . getSwitcher(FEATURE01 );
183+ switcher. isItOn();
184+ ```
185+
186+
170187## Real-time snapshot updater
171188Let the Switcher Client manage your application local snapshot file.
172189
0 commit comments