Skip to content

Commit b3457e4

Browse files
authored
Merge pull request #76 from switcherapi/release_120
Release 120
2 parents 3249d92 + 74df6b0 commit b3457e4

2 files changed

Lines changed: 31 additions & 14 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<groupId>com.github.switcherapi</groupId>
99
<artifactId>switcher-client</artifactId>
1010
<packaging>jar</packaging>
11-
<version>1.2.0-SNAPSHOT</version>
11+
<version>1.2.0</version>
1212

1313
<name>Switcher Client</name>
1414
<description>Switcher Client for working with Switcher API</description>

readme.md

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
Client Java for working with Switcher-API.
1212
https://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.
3636
This new approach has eliminated unnecessary boilerplates and also has added a new layer for security purposes.
3737

3838
Similarly 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
4949
switcher.environment -> Environment name. Production environment is named as 'default'
5050
switcher.domain -> Domain name
5151
5252
#optional
5353
switcher.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
5757
switcher.silent -> true/false Contingency in case of some problem with connectivity with the API
5858
switcher.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);
133133
3. **Strategy validation - chained call**
134134
Create chained calls using 'getSwitcher' then 'prepareEntry' then 'isItOn' functions.
135135

136+
136137
```java
138+
@Deprecated
137139
Switcher 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
156158
switcher.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
163168
properties.put(SwitcherContextParam.SNAPSHOT_LOCATION, "/src/resources");
164169
SwitcherFactory.buildContext(properties, true);
165170

166171
Switcher switcher = MyAppFeatures.getSwitcher(FEATURE01);
167172
switcher.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
171188
Let the Switcher Client manage your application local snapshot file.
172189

0 commit comments

Comments
 (0)