Skip to content

Commit 00a7765

Browse files
author
Mike Davis
authored
Update README.md for notifications and builder methods. (#317)
1 parent a0d0ccb commit 00a7765

File tree

1 file changed

+56
-15
lines changed

1 file changed

+56
-15
lines changed

core-httpclient-impl/README.md

Lines changed: 56 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class App {
6565
}
6666
```
6767

68-
## `AsyncEventHandler`
68+
## AsyncEventHandler
6969

7070
[`AsyncEventHandler`](https://github.com/optimizely/java-sdk/blob/master/core-httpclient-impl/src/main/java/com/optimizely/ab/event/AsyncEventHandler.java)
7171
provides an implementation of [`EventHandler`](https://github.com/optimizely/java-sdk/blob/master/core-api/src/main/java/com/optimizely/ab/event/EventHandler.java)
@@ -97,18 +97,30 @@ memory if the workers cannot keep up with the production rate.
9797

9898
The number of workers determines the number of threads the thread pool uses.
9999

100+
### Builder Methods
101+
The following builder methods can be used to custom configure the `AsyncEventHandler`.
102+
103+
|Method Name|Default Value|Description|
104+
|---|---|---|
105+
|`withQueueCapacity(int)`|10000|Queue size for pending logEvents|
106+
|`withNumWorkers(int)`|2|Number of worker threads|
107+
|`withMaxTotalConnections(int)`|200|Maximum number of connections|
108+
|`withMaxPerRoute(int)`|20|Maximum number of connections per route|
109+
|`withValidateAfterInactivity(int)`|5000|Time to maintain idol connections (in milliseconds)|
110+
100111
### Advanced configuration
112+
The following properties can be set to override the default configuration.
101113

102114
|Property Name|Default Value|Description|
103115
|---|---|---|
104-
|`async.event.handler.queue.capacity`|10000|Queue size for pending logEvents|
105-
|`async.event.handler.num.workers`|2|Number of worker threads|
106-
|`async.event.handler.max.connections`|200|Maximum number of connections|
107-
|`async.event.handler.event.max.per.route`|20|Maximum number of connections per route|
108-
|`async.event.handler.validate.after`|5000|Time to maintain idol connections (in milliseconds)|
116+
|**async.event.handler.queue.capacity**|10000|Queue size for pending logEvents|
117+
|**async.event.handler.num.workers**|2|Number of worker threads|
118+
|**async.event.handler.max.connections**|200|Maximum number of connections|
119+
|**async.event.handler.event.max.per.route**|20|Maximum number of connections per route|
120+
|**async.event.handler.validate.after**|5000|Time to maintain idol connections (in milliseconds)|
109121

110122

111-
## `HttpProjectConfigManager`
123+
## HttpProjectConfigManager
112124

113125
[`HttpProjectConfigManager`](https://github.com/optimizely/java-sdk/blob/master/core-httpclient-impl/src/main/java/com/optimizely/ab/config/HttpProjectConfigManager.java)
114126
is an implementation of the abstract [`PollingProjectConfigManager`](https://github.com/optimizely/java-sdk/blob/master/core-api/src/main/java/com/optimizely/ab/config/PollingProjectConfigManager.java).
@@ -139,20 +151,49 @@ The polling interval is used to specify a fixed delay between consecutive HTTP r
139151
#### Initial datafile
140152

141153
You can provide an initial datafile via the builder to bootstrap the `ProjectConfigManager` so that it can be used
142-
immediately without blocking execution.
154+
immediately without blocking execution. The initial datafile also serves as a fallback datafile if HTTP connection
155+
cannot be established. This is useful in mobile environments, where internet connectivity is not guaranteed.
156+
The initial datafile will be discarded after the first successful datafile poll.
157+
158+
### Builder Methods
159+
The following builder methods can be used to custom configure the `HttpProjectConfigManager`.
160+
161+
|Builder Method|Default Value|Description|
162+
|---|---|---|
163+
|`withDatafile(String)`|null|Initial datafile, typically sourced from a local cached source.|
164+
|`withUrl(String)`|null|URL override location used to specify custom HTTP source for the Optimizely datafile.|
165+
|`withFormat(String)`|https://cdn.optimizely.com/datafiles/%s.json|Parameterized datafile URL by SDK key.|
166+
|`withPollingInterval(Long, TimeUnit)`|5 minutes|Fixed delay between fetches for the datafile.|
167+
|`withBlockingTimeout(Long, TimeUnit)`|10 seconds|Maximum time to wait for initial bootstrapping.|
168+
|`withSdkKey(String)`|null|Optimizely project SDK key. Required unless source URL is overridden.|
143169

144170
### Advanced configuration
171+
The following properties can be set to override the default configuration.
145172

146173
|Property Name|Default Value|Description|
147174
|---|---|---|
148-
|`http.project.config.manager.polling.duration`|5|Fixed delay between fetches for the datafile|
149-
|`http.project.config.manager.polling.unit`|MINUTES|Time unit corresponding to polling interval|
150-
|`http.project.config.manager.blocking.duration`|10|Maximum time to wait for initial bootstrapping|
151-
|`http.project.config.manager.blocking.unit`|SECONDS|Time unit corresponding to blocking duration|
152-
|`http.project.config.manager.sdk.key`|null|Optimizely project SDK key|
175+
|**http.project.config.manager.polling.duration**|5|Fixed delay between fetches for the datafile|
176+
|**http.project.config.manager.polling.unit**|MINUTES|Time unit corresponding to polling interval|
177+
|**http.project.config.manager.blocking.duration**|10|Maximum time to wait for initial bootstrapping|
178+
|**http.project.config.manager.blocking.unit**|SECONDS|Time unit corresponding to blocking duration|
179+
|**http.project.config.manager.sdk.key**|null|Optimizely project SDK key|
153180

181+
## Update Config Notifications
182+
A notification signal will be triggered whenever a _new_ datafile is fetched. To subscribe to these notifications you can
183+
use the `Optimizely.addUpdateConfigNotificationHandler`:
184+
185+
```java
186+
NotificationHandler<UpdateConfigNotification> handler = message ->
187+
System.out.println("Received new datafile configuration");
188+
189+
optimizely.addUpdateConfigNotificationHandler(handler);
190+
```
191+
or add the handler directly to the `NotificationCenter`:
192+
```java
193+
notificationCenter.addNotificationHandler(UpdateConfigNotification.class, handler);
194+
```
154195

155-
## `optimizely.properties`
196+
## optimizely.properties
156197

157198
When an `optimizely.properties` file is available within the runtime classpath it can be used to provide
158199
default values of a given Optimizely resource. Refer to the resource implementation for available configuration parameters.
@@ -168,7 +209,7 @@ async.event.handler.num.workers = 5
168209
```
169210

170211

171-
## `OptimizelyFactory`
212+
## OptimizelyFactory
172213

173214
In this package, [`OptimizelyFactory`](https://github.com/optimizely/java-sdk/blob/master/core-httpclient-impl/src/main/java/com/optimizely/ab/OptimizelyFactory.java)
174215
provides basic utility to instantiate the Optimizely SDK with a minimal number of configuration options.

0 commit comments

Comments
 (0)