Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
All notable changes to the LaunchDarkly Java SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).

## [3.0.0] - 2018-02-21
### Added
- Support for a new LaunchDarkly feature: reusable user segments.

### Changed
- The `FeatureStore` interface has been changed to support user segment data as well as feature flags. Existing code that uses `InMemoryFeatureStore` or `RedisFeatureStore` should work as before, but custom feature store implementations will need to be updated.
- Removed deprecated methods.
_This release was broken and should not be used._


## [2.6.0] - 2018-02-12
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Quick setup
<dependency>
<groupId>com.launchdarkly</groupId>
<artifactId>launchdarkly-client</artifactId>
<version>3.0.0</version>
<version>2.6.0</version>
</dependency>

1. Import the LaunchDarkly package:
Expand Down
32 changes: 25 additions & 7 deletions src/main/java/com/launchdarkly/client/StreamProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.SettableFuture;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
Expand Down Expand Up @@ -83,8 +84,8 @@ public void onMessage(String name, MessageEvent event) throws Exception {
Gson gson = new Gson();
switch (name) {
case PUT: {
FeatureRequestor.AllData allData = gson.fromJson(event.getData(), FeatureRequestor.AllData.class);
store.init(FeatureRequestor.toVersionedDataMap(allData));
PutData putData = gson.fromJson(event.getData(), PutData.class);
store.init(FeatureRequestor.toVersionedDataMap(putData.data));
if (!initialized.getAndSet(true)) {
initFuture.set(null);
logger.info("Initialized LaunchDarkly client.");
Expand Down Expand Up @@ -161,8 +162,19 @@ public void onError(Throwable throwable) {
}
};

es = createEventSource(handler,
URI.create(config.streamURI.toASCIIString() + "/all"),
connectionErrorHandler,
headers);
es.start();
return initFuture;
}

@VisibleForTesting
protected EventSource createEventSource(EventHandler handler, URI streamUri, ConnectionErrorHandler errorHandler,
Headers headers) {
EventSource.Builder builder = new EventSource.Builder(handler, URI.create(config.streamURI.toASCIIString() + "/all"))
.connectionErrorHandler(connectionErrorHandler)
.connectionErrorHandler(errorHandler)
.headers(headers)
.reconnectTimeMs(config.reconnectTimeMs)
.connectTimeoutMs(config.connectTimeoutMillis)
Expand All @@ -179,11 +191,9 @@ public void onError(Throwable throwable) {
}
}

es = builder.build();
es.start();
return initFuture;
return builder.build();
}

@Override
public void close() throws IOException {
logger.info("Closing LaunchDarkly StreamProcessor");
Expand All @@ -200,6 +210,14 @@ public boolean initialized() {
return initialized.get();
}

private static final class PutData {
FeatureRequestor.AllData data;

public PutData() {

}
}

private static final class PatchData {
String path;
JsonElement data;
Expand Down
Loading