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
Show all changes
83 commits
Select commit Hold shift + click to select a range
a574ef4
initial commit of event summary logic, with naive synchronization
eli-darkly Mar 7, 2018
4f96e34
use LRU cache for user keys
eli-darkly Mar 8, 2018
da4647d
do summary output generation outside of mutex
eli-darkly Mar 8, 2018
d99fbcb
test cleanup
eli-darkly Mar 8, 2018
b236380
make summarization independent of whether event is tracked in detail
eli-darkly Mar 9, 2018
27b412f
test improvements
eli-darkly Mar 9, 2018
a74f1b9
typo
eli-darkly Mar 9, 2018
9f71981
improve synchronization, clean up event classes
eli-darkly Mar 9, 2018
39398f4
fix test method names
eli-darkly Mar 10, 2018
5d07562
fix client tests
eli-darkly Mar 10, 2018
0475744
add debugging
eli-darkly Mar 10, 2018
ea4c7fd
more debugging
eli-darkly Mar 10, 2018
74ca6f7
more debugging
eli-darkly Mar 10, 2018
647cba8
use semaphore + more debugging
eli-darkly Mar 10, 2018
bf5a63c
less debugging
eli-darkly Mar 10, 2018
00ea846
increase timeouts on PollingProcessor tests
eli-darkly Mar 10, 2018
d47e364
increase timeouts on PollingProcessor tests
eli-darkly Mar 10, 2018
edf5e26
comment
eli-darkly Mar 10, 2018
2d99605
add "debug" event kind
eli-darkly Mar 12, 2018
603eb21
update for latest summary event schema with features map
eli-darkly Mar 13, 2018
72881ca
update for change in spec: inline users can now be retained optionally
eli-darkly Mar 13, 2018
ec71709
don't include variation index in feature event
eli-darkly Mar 14, 2018
9640631
typo
eli-darkly Mar 14, 2018
1782ac6
misc cleanup
eli-darkly Mar 15, 2018
db5a4e9
make EventProcessor into an interface; always send events asynchronously
eli-darkly Mar 15, 2018
0a92346
make all event fields final
eli-darkly Mar 15, 2018
545460a
rm unused method
eli-darkly Mar 15, 2018
5f0faa1
rm unnecessary result state
eli-darkly Mar 16, 2018
5e9b575
don't return early if index event can't be queued
eli-darkly Mar 16, 2018
9d37263
don't need AtomicBoolean
eli-darkly Mar 16, 2018
83eb47b
fix test class name
eli-darkly Mar 16, 2018
b392392
add test for flushing empty queue
eli-darkly Mar 16, 2018
2fd75b0
revise the "last known server time" logic - it was the reverse of wha…
eli-darkly Mar 19, 2018
05e0baf
Merge branch 'master' into summary-events
eli-darkly Mar 22, 2018
8171070
Merge branch 'summary-events' into eb/ch12902/summary-events
eli-darkly Mar 22, 2018
ad381db
rm duplicate class
eli-darkly Mar 22, 2018
c0fcacb
add tests for user filtering in events
eli-darkly Mar 22, 2018
141df39
fix unit tests to verify that a summary event is present
eli-darkly Mar 22, 2018
5ec76f5
misc fixes
eli-darkly Mar 22, 2018
cea6cf9
reorganize inner classes, make event processor responsible for summar…
eli-darkly Mar 25, 2018
87103c6
more reorganization - breaking up DefaultEventProcessor into 3 classes
eli-darkly Mar 25, 2018
09f73ef
avoid repeating log warning
eli-darkly Mar 26, 2018
3254df4
reorganize event processor code; make flushes async, except during Close
eli-darkly Mar 28, 2018
4f2c916
reorganize & expand LDClient tests; simplify logic for creating updat…
eli-darkly Mar 28, 2018
50fdfba
misc cleanup
eli-darkly Mar 28, 2018
9d54076
migrate to Circle 2
eli-darkly Mar 29, 2018
4b744f8
Merge pull request #62 from launchdarkly/eb/ch15552/circle2
eli-darkly Mar 29, 2018
22db082
Merge branch 'master' into summary-events
eli-darkly Mar 30, 2018
e122191
Merge branch 'summary-events' into eb/ch12902/summary-events
eli-darkly Mar 30, 2018
6c53d6b
fix merge
eli-darkly Mar 30, 2018
d0e0ce5
use a fixed pool of flush workers; move some of the flush logic back …
eli-darkly Mar 30, 2018
8a0742a
big refactoring
eli-darkly Apr 3, 2018
99ed685
misc cleanup
eli-darkly Apr 3, 2018
238c9df
comment
eli-darkly Apr 3, 2018
65f7b64
misc cleanup
eli-darkly Apr 3, 2018
ad099e7
better error message
eli-darkly Apr 3, 2018
df1f960
misc cleanup
eli-darkly Apr 3, 2018
d6002cc
misc cleanup
eli-darkly Apr 3, 2018
d59bbf9
add event schema version header
eli-darkly Apr 9, 2018
de45c4a
move getRequestBuilder out of Config, it's not an instance method
eli-darkly Apr 9, 2018
2cab994
debug events should be in addition to regular events, & should always…
eli-darkly Apr 9, 2018
613b8e9
add unit test
eli-darkly Apr 9, 2018
9331456
retry event posting once on exception or 5xx error
eli-darkly Apr 10, 2018
ab03f47
misc cleanup
eli-darkly Apr 12, 2018
cbdfda0
Merge branch 'eb/ch12902/summary-events-2' into eb/ch15679/summary-ev…
eli-darkly Apr 12, 2018
fd9b02d
send as much of a feature event as possible even if user is invalid
eli-darkly Apr 25, 2018
739aefe
delay should apply to all attempts after the first one
eli-darkly Apr 25, 2018
7e46081
use factories for all pluggable components
eli-darkly Apr 26, 2018
89633ef
make LDClient final, remove methods that were overrideable only for t…
eli-darkly Apr 26, 2018
2b935e8
rm duplicate logging
eli-darkly Apr 26, 2018
a6757ab
add variation index to feature events and summary counters
eli-darkly Apr 27, 2018
dec738e
Event classes should be public
eli-darkly Apr 30, 2018
1cb7578
Merge pull request #56 from launchdarkly/eb/ch12902/summary-events
eli-darkly Apr 30, 2018
316122d
Merge branch 'eb/ch12902/summary-events' into eb/ch12902/summary-even…
eli-darkly Apr 30, 2018
aaeab21
Merge pull request #64 from launchdarkly/eb/ch12902/summary-events-2
eli-darkly Apr 30, 2018
65724fa
Merge branch 'summary-events' into eb/ch15679/summary-events-3
eli-darkly Apr 30, 2018
9311823
Merge pull request #65 from launchdarkly/eb/ch15679/summary-events-3
eli-darkly Apr 30, 2018
895c503
Merge pull request #66 from launchdarkly/eb/summary-events-4
eli-darkly Apr 30, 2018
f9fc7a5
Merge pull request #69 from launchdarkly/eb/ch16654/variation-index
eli-darkly May 4, 2018
dd1ee9c
deprecate TestFeatureStore
eli-darkly May 9, 2018
8e170e9
Merge pull request #61 from launchdarkly/eb/client-tests
eli-darkly May 9, 2018
0a53bde
Merge branch 'summary-events' into eb/interfaces-and-factories
eli-darkly May 9, 2018
a6e289d
Merge pull request #67 from launchdarkly/eb/interfaces-and-factories
eli-darkly May 9, 2018
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
24 changes: 24 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: 2
jobs:
build:
branches:
ignore:
- gh-pages
docker:
- image: circleci/java
- image: redis
steps:
- checkout
- run: cp gradle.properties.example gradle.properties
- run: ./gradlew dependencies
- run: ./gradlew test
- run:
name: Save test results
command: |
mkdir -p ~/junit/
find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/junit/ \;
when: always
- store_test_results:
path: ~/junit
- store_artifacts:
path: ~/junit
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ libraries.unshaded = [
]

libraries.testCompile = [
"com.squareup.okhttp3:mockwebserver:3.10.0",
"org.hamcrest:hamcrest-all:1.3",
"org.easymock:easymock:3.4",
"junit:junit:4.12"
]
Expand Down
16 changes: 0 additions & 16 deletions circle.yml

This file was deleted.

132 changes: 132 additions & 0 deletions src/main/java/com/launchdarkly/client/Components.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package com.launchdarkly.client;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.URI;

/**
* Provides factories for the standard implementations of LaunchDarkly component interfaces.
* @since 4.0.0
*/
public abstract class Components {
private static final FeatureStoreFactory inMemoryFeatureStoreFactory = new InMemoryFeatureStoreFactory();
private static final EventProcessorFactory defaultEventProcessorFactory = new DefaultEventProcessorFactory();
private static final EventProcessorFactory nullEventProcessorFactory = new NullEventProcessorFactory();
private static final UpdateProcessorFactory defaultUpdateProcessorFactory = new DefaultUpdateProcessorFactory();
private static final UpdateProcessorFactory nullUpdateProcessorFactory = new NullUpdateProcessorFactory();

/**
* Returns a factory for the default in-memory implementation of {@link FeatureStore}.
*/
public static FeatureStoreFactory inMemoryFeatureStore() {
return inMemoryFeatureStoreFactory;
}

/**
* Returns a factory with builder methods for creating a Redis-backed implementation of {@link FeatureStore},
* using {@link RedisFeatureStoreBuilder#DEFAULT_URI}.
*/
public static RedisFeatureStoreBuilder redisFeatureStore() {
return new RedisFeatureStoreBuilder();
}

/**
* Returns a factory with builder methods for creating a Redis-backed implementation of {@link FeatureStore},
* specifying the Redis URI.
*/
public static RedisFeatureStoreBuilder redisFeatureStore(URI redisUri) {
return new RedisFeatureStoreBuilder(redisUri);
}

/**
* Returns a factory for the default implementation of {@link EventProcessor}, which
* forwards all analytics events to LaunchDarkly (unless the client is offline or you have
* set {@link LDConfig.Builder#sendEvents(boolean)} to {@code false}).
*/
public static EventProcessorFactory defaultEventProcessor() {
return defaultEventProcessorFactory;
}

/**
* Returns a factory for a null implementation of {@link EventProcessor}, which will discard
* all analytics events and not send them to LaunchDarkly, regardless of any other configuration.
*/
public static EventProcessorFactory nullEventProcessor() {
return nullEventProcessorFactory;
}

/**
* Returns a factory for the default implementation of {@link UpdateProcessor}, which receives
* feature flag data from LaunchDarkly using either streaming or polling as configured (or does
* nothing if the client is offline, or in LDD mode).
*/
public static UpdateProcessorFactory defaultUpdateProcessor() {
return defaultUpdateProcessorFactory;
}

/**
* Returns a factory for a null implementation of {@link UpdateProcessor}, which does not
* connect to LaunchDarkly, regardless of any other configuration.
*/
public static UpdateProcessorFactory nullUpdateProcessor() {
return nullUpdateProcessorFactory;
}

private static final class InMemoryFeatureStoreFactory implements FeatureStoreFactory {
@Override
public FeatureStore createFeatureStore() {
return new InMemoryFeatureStore();
}
}

private static final class DefaultEventProcessorFactory implements EventProcessorFactory {
@Override
public EventProcessor createEventProcessor(String sdkKey, LDConfig config) {
if (config.offline || !config.sendEvents) {
return new EventProcessor.NullEventProcessor();
} else {
return new DefaultEventProcessor(sdkKey, config);
}
}
}

private static final class NullEventProcessorFactory implements EventProcessorFactory {
public EventProcessor createEventProcessor(String sdkKey, LDConfig config) {
return new EventProcessor.NullEventProcessor();
}
}

private static final class DefaultUpdateProcessorFactory implements UpdateProcessorFactory {
// Note, logger uses LDClient class name for backward compatibility
private static final Logger logger = LoggerFactory.getLogger(LDClient.class);

@Override
public UpdateProcessor createUpdateProcessor(String sdkKey, LDConfig config, FeatureStore featureStore) {
if (config.offline) {
logger.info("Starting LaunchDarkly client in offline mode");
return new UpdateProcessor.NullUpdateProcessor();
} else if (config.useLdd) {
logger.info("Starting LaunchDarkly in LDD mode. Skipping direct feature retrieval.");
return new UpdateProcessor.NullUpdateProcessor();
} else {
FeatureRequestor requestor = new FeatureRequestor(sdkKey, config);
if (config.stream) {
logger.info("Enabling streaming API");
return new StreamProcessor(sdkKey, config, requestor, featureStore);
} else {
logger.info("Disabling streaming API");
logger.warn("You should only disable the streaming API if instructed to do so by LaunchDarkly support");
return new PollingProcessor(config, requestor, featureStore);
}
}
}
}

private static final class NullUpdateProcessorFactory implements UpdateProcessorFactory {
@Override
public UpdateProcessor createUpdateProcessor(String sdkKey, LDConfig config, FeatureStore featureStore) {
return new UpdateProcessor.NullUpdateProcessor();
}
}
}
12 changes: 0 additions & 12 deletions src/main/java/com/launchdarkly/client/CustomEvent.java

This file was deleted.

Loading