attributes,
+ EvaluationOptions evaluationOptions);
/**
* Destroys the background processes and clears the cache, releasing the resources used by
@@ -146,6 +953,53 @@ public interface SplitClient {
*/
void destroy();
+ /**
+ * Registers {@code callback} to run when {@code event} fires, ignoring the event details.
+ * Equivalent to {@link #on(SdkEvent, SdkEventListener)} with a listener that discards its metadata.
+ *
+ * @param event the event to subscribe to. If null a warning is logged and the call is ignored.
+ * @param callback invoked each time the event fires. If null a warning is logged and the call is ignored.
+ * @see #on(SdkEvent, SdkEventListener)
+ */
+ void on(SdkEvent event, Runnable callback);
+
+ /**
+ * Registers {@code listener} to be invoked when {@code event} fires.
+ *
+ * Any number of listeners can be registered for the same event, including the same listener more than once;
+ * each registration is invoked, in registration order. Listeners run on an SDK-owned thread, never on the caller's
+ * thread, and an exception thrown by one listener does not prevent the others from running.
+ *
+ *
Per event:
+ *
+ * - {@link SdkEvent#SDK_READY}: fires once, when feature flags and segments are available. Metadata has
+ * {@code isInitialCacheLoad()} and {@code getLastUpdateTimestamp()} populated (the timestamp may be null);
+ * {@code getType()} is null and {@code getNames()} is empty. A listener registered after the event already
+ * fired is still invoked once, asynchronously, with {@code null} metadata.
+ * - {@link SdkEvent#SDK_READY_TIMED_OUT}: fires once if {@link #blockUntilReady()} times out, and is not
+ * emitted if the SDK became ready first. Metadata is always {@code null}; it is replayed to late
+ * subscribers like {@code SDK_READY}.
+ * - {@link SdkEvent#SDK_UPDATE}: fires every time feature flags or segments change after the SDK became
+ * ready. Metadata has {@code getType()} and {@code getNames()} populated (the flag names for a flag update;
+ * empty for segment updates). It is never replayed to late subscribers. It is not available in consumer
+ * mode, where no update event is ever produced.
+ *
+ *
+ * Registering after {@link #destroy()} is a silent no-op.
+ *
+ * @param event the event to subscribe to. If null a warning is logged and the call is ignored.
+ * @param listener invoked when the event fires. If null a warning is logged and the call is ignored.
+ */
+ void on(SdkEvent event, SdkEventListener listener);
+
+ /**
+ * Removes every listener registered for {@code event}. Other events are not affected, and new listeners can
+ * still be registered for {@code event} afterwards.
+ *
+ * @param event the event whose listeners are removed. If null a warning is logged and the call is ignored.
+ */
+ void off(SdkEvent event);
+
/**
* Enqueue a new event to be sent to split data collection services
*
@@ -184,7 +1038,6 @@ public interface SplitClient {
* @param key the identifier of the entity
* @param trafficType the type of the event
* @param eventType the type of the event
- * @param value the value of the event
*
* @return true if the track was successful, false otherwise
*/
@@ -218,4 +1071,4 @@ public interface SplitClient {
*
*/
void blockUntilReady() throws TimeoutException, InterruptedException;
-}
+}
\ No newline at end of file
diff --git a/client/src/main/java/io/split/client/SplitClientConfig.java b/client/src/main/java/io/split/client/SplitClientConfig.java
index cafd52eb..3a38fccd 100644
--- a/client/src/main/java/io/split/client/SplitClientConfig.java
+++ b/client/src/main/java/io/split/client/SplitClientConfig.java
@@ -1,13 +1,31 @@
package io.split.client;
-
+import io.split.client.dtos.FallbackTreatment;
+import io.split.client.dtos.FallbackTreatmentsConfiguration;
+import io.split.client.dtos.ProxyConfiguration;
import io.split.client.impressions.ImpressionListener;
import io.split.client.impressions.ImpressionsManager;
+import io.split.client.utils.FileTypeEnum;
import io.split.integrations.IntegrationsConfig;
+import io.split.service.CustomHttpModule;
+import io.split.storages.enums.OperationMode;
+import io.split.storages.enums.StorageMode;
import org.apache.hc.core5.http.HttpHost;
+import org.slf4j.LoggerFactory;
+import pluggable.CustomStorageWrapper;
import java.io.IOException;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
import java.util.Properties;
+import java.util.concurrent.ThreadFactory;
+import java.io.InputStream;
+
+import static io.split.inputValidation.FallbackTreatmentValidator.isValidByFlagTreatment;
+import static io.split.inputValidation.FallbackTreatmentValidator.isValidTreatment;
+import static io.split.inputValidation.FlagSetsValidator.cleanup;
/**
* Configurations for the SplitClient.
@@ -16,7 +34,21 @@
*/
public class SplitClientConfig {
+ private static final org.slf4j.Logger _log = LoggerFactory.getLogger(SplitClientConfig.class);
public static final String LOCALHOST_DEFAULT_FILE = "split.yaml";
+ public static final String SDK_ENDPOINT = "https://sdk.split.io";
+ public static final String EVENTS_ENDPOINT = "https://events.split.io";
+ public static final String AUTH_ENDPOINT = "https://auth.split.io/api/v2/auth";
+ public static final String STREAMING_ENDPOINT = "https://streaming.split.io/sse";
+ public static final String TELEMETRY_ENDPOINT = "https://telemetry.split.io/api/v1";
+
+ public static class HttpScheme {
+ private HttpScheme() {
+ throw new IllegalStateException("Utility class");
+ }
+ public static final String HTTP = "http";
+ public static final String HTTPS = "https";
+ }
private final String _endpoint;
private final String _eventsEndpoint;
@@ -33,28 +65,52 @@ public class SplitClientConfig {
private final boolean _debugEnabled;
private final boolean _labelsEnabled;
private final boolean _ipAddressEnabled;
+ private final boolean _localhostRefreshEnabled;
private final int _ready;
private final int _waitBeforeShutdown;
private final int _eventsQueueSize;
- private final long _eventFlushIntervalInMillis;
+ private final long _eventSendIntervalInMillis;
private final int _maxStringLength;
private final boolean _destroyOnShutDown;
private final String _splitFile;
+ private final FileTypeEnum _fileType;
+ private final InputStream _inputStream;
+ private final String _segmentDirectory;
private final IntegrationsConfig _integrationsConfig;
private final boolean _streamingEnabled;
private final int _authRetryBackoffBase;
private final int _streamingReconnectBackoffBase;
private final String _authServiceURL;
private final String _streamingServiceURL;
+ private final String _telemetryURL;
+ private final int _telemetryRefreshRate;
+ private final int _onDemandFetchRetryDelayMs;
+ private final int _onDemandFetchMaxRetries;
+ private final int _failedAttemptsBeforeLogging;
+ private final int _uniqueKeysRefreshRateInMemory;
+ private final int _uniqueKeysRefreshRateRedis;
+ private static int _filterUniqueKeysRefreshRate;
+ private final OperationMode _operationMode;
+ private long _validateAfterInactivityInMillis;
+ private final long _startingSyncCallBackoffBaseMs;
+ private final CustomStorageWrapper _customStorageWrapper;
+ private final StorageMode _storageMode;
+ private final ThreadFactory _threadFactory;
+ private final FallbackTreatmentsConfiguration _fallbackTreatments;
// Proxy configs
+ private final ProxyConfiguration _proxyConfiguration;
private final HttpHost _proxy;
private final String _proxyUsername;
private final String _proxyPassword;
// To be set during startup
public static String splitSdkVersion;
-
+ private final long _lastSeenCacheSize;
+ private final HashSet _flagSetsFilter;
+ private final int _invalidSets;
+ private final CustomHeaderDecorator _customHeaderDecorator;
+ private final CustomHttpModule _alternativeHTTPModule;
public static Builder builder() {
return new Builder();
@@ -75,21 +131,46 @@ private SplitClientConfig(String endpoint,
boolean debugEnabled,
boolean labelsEnabled,
boolean ipAddressEnabled,
+ boolean localhostRefreshEnabled,
int waitBeforeShutdown,
HttpHost proxy,
String proxyUsername,
String proxyPassword,
+ ProxyConfiguration proxyConfiguration,
int eventsQueueSize,
- long eventFlushIntervalInMillis,
+ long eventSendIntervalInMillis,
int maxStringLength,
boolean destroyOnShutDown,
String splitFile,
+ FileTypeEnum fileType,
+ InputStream inputStream,
+ String segmentDirectory,
IntegrationsConfig integrationsConfig,
boolean streamingEnabled,
int authRetryBackoffBase,
int streamingReconnectBackoffBase,
String authServiceURL,
- String streamingServiceURL) {
+ String streamingServiceURL,
+ String telemetryURL,
+ int telemetryRefreshRate,
+ int onDemandFetchRetryDelayMs,
+ int onDemandFetchMaxRetries,
+ int failedAttemptsBeforeLogging,
+ OperationMode operationMode,
+ long validateAfterInactivityInMillis,
+ long startingSyncCallBackoffBaseMs,
+ CustomStorageWrapper customStorageWrapper,
+ StorageMode storageMode,
+ int uniqueKeysRefreshRateInMemory,
+ int uniqueKeysRefreshRateRedis,
+ int filterUniqueKeysRefreshRate,
+ long lastSeenCacheSize,
+ ThreadFactory threadFactory,
+ HashSet flagSetsFilter,
+ int invalidSets,
+ CustomHeaderDecorator customHeaderDecorator,
+ CustomHttpModule alternativeHTTPModule,
+ FallbackTreatmentsConfiguration fallbackTreatments) {
_endpoint = endpoint;
_eventsEndpoint = eventsEndpoint;
_featuresRefreshRate = pollForFeatureChangesEveryNSeconds;
@@ -105,21 +186,46 @@ private SplitClientConfig(String endpoint,
_debugEnabled = debugEnabled;
_labelsEnabled = labelsEnabled;
_ipAddressEnabled = ipAddressEnabled;
+ _localhostRefreshEnabled = localhostRefreshEnabled;
_waitBeforeShutdown = waitBeforeShutdown;
_proxy = proxy;
_proxyUsername = proxyUsername;
_proxyPassword = proxyPassword;
+ _proxyConfiguration = proxyConfiguration;
_eventsQueueSize = eventsQueueSize;
- _eventFlushIntervalInMillis = eventFlushIntervalInMillis;
+ _eventSendIntervalInMillis = eventSendIntervalInMillis;
_maxStringLength = maxStringLength;
_destroyOnShutDown = destroyOnShutDown;
_splitFile = splitFile;
+ _fileType = fileType;
+ _inputStream = inputStream;
+ _segmentDirectory = segmentDirectory;
_integrationsConfig = integrationsConfig;
_streamingEnabled = streamingEnabled;
_authRetryBackoffBase = authRetryBackoffBase;
_streamingReconnectBackoffBase = streamingReconnectBackoffBase;
_authServiceURL = authServiceURL;
_streamingServiceURL = streamingServiceURL;
+ _telemetryURL = telemetryURL;
+ _telemetryRefreshRate = telemetryRefreshRate;
+ _uniqueKeysRefreshRateInMemory = uniqueKeysRefreshRateInMemory;
+ _uniqueKeysRefreshRateRedis = uniqueKeysRefreshRateRedis;
+ _filterUniqueKeysRefreshRate = filterUniqueKeysRefreshRate;
+ _onDemandFetchRetryDelayMs = onDemandFetchRetryDelayMs;
+ _onDemandFetchMaxRetries = onDemandFetchMaxRetries;
+ _failedAttemptsBeforeLogging = failedAttemptsBeforeLogging;
+ _operationMode = operationMode;
+ _storageMode = storageMode;
+ _validateAfterInactivityInMillis = validateAfterInactivityInMillis;
+ _startingSyncCallBackoffBaseMs = startingSyncCallBackoffBaseMs;
+ _customStorageWrapper = customStorageWrapper;
+ _lastSeenCacheSize = lastSeenCacheSize;
+ _threadFactory = threadFactory;
+ _flagSetsFilter = flagSetsFilter;
+ _invalidSets = invalidSets;
+ _customHeaderDecorator = customHeaderDecorator;
+ _alternativeHTTPModule = alternativeHTTPModule;
+ _fallbackTreatments = fallbackTreatments;
Properties props = new Properties();
try {
@@ -158,6 +264,16 @@ public int impressionsRefreshRate() {
return _impressionsRefreshRate;
}
+ public int uniqueKeysRefreshRateInMemory() {
+ return _uniqueKeysRefreshRateInMemory;
+ }
+ public int uniqueKeysRefreshRateRedis() {
+ return _uniqueKeysRefreshRateRedis;
+ }
+ public static int filterUniqueKeysRefreshRate() {
+ return _filterUniqueKeysRefreshRate;
+ }
+
public int impressionsQueueSize() {
return _impressionsQueueSize;
}
@@ -184,6 +300,10 @@ public boolean debugEnabled() {
public boolean ipAddressEnabled() { return _ipAddressEnabled; }
+ public boolean localhostRefreshEnabled() {
+ return _localhostRefreshEnabled;
+ }
+
public int blockUntilReady() {
return _ready;
}
@@ -204,8 +324,12 @@ public String proxyPassword() {
return _proxyPassword;
}
- public long eventFlushIntervalInMillis() {
- return _eventFlushIntervalInMillis;
+ public ProxyConfiguration proxyConfiguration() {
+ return _proxyConfiguration;
+ }
+
+ public long eventSendIntervalInMillis() {
+ return _eventSendIntervalInMillis;
}
public int eventsQueueSize() {
@@ -224,6 +348,18 @@ public String splitFile() {
return _splitFile;
}
+ public FileTypeEnum fileType() {
+ return _fileType;
+ }
+
+ public InputStream inputStream(){
+ return _inputStream;
+ }
+
+ public String segmentDirectory() {
+ return _segmentDirectory;
+ }
+
public IntegrationsConfig integrationsConfig() {
return _integrationsConfig;
}
@@ -248,11 +384,72 @@ public String streamingServiceURL() {
return _streamingServiceURL;
}
- public static final class Builder {
+ public String telemetryURL() {
+ return _telemetryURL;
+ }
+
+ /**
+ * @deprecated As of release 4.X.X, replaced by {@link #getTelemetryRefreshRate()} } //todo update version
+ **/
+ @Deprecated
+ public int get_telemetryRefreshRate() {
+ return _telemetryRefreshRate;
+ }
+
+ public int getTelemetryRefreshRate() {
+ return _telemetryRefreshRate;
+ }
+ public int streamingRetryDelay() {return _onDemandFetchRetryDelayMs;}
+
+ public int streamingFetchMaxRetries() {return _onDemandFetchMaxRetries;}
+
+ public int failedAttemptsBeforeLogging() {return _failedAttemptsBeforeLogging;}
+
+ public OperationMode operationMode() { return _operationMode;}
+
+ public long validateAfterInactivityInMillis() {
+ return _validateAfterInactivityInMillis;
+ }
+ public long startingSyncCallBackoffBaseMs(){ return _startingSyncCallBackoffBaseMs;}
+
+ public CustomStorageWrapper customStorageWrapper() {
+ return _customStorageWrapper;
+ }
+
+ public StorageMode storageMode() { return _storageMode;}
+
+ public long getLastSeenCacheSize() {
+ return _lastSeenCacheSize;
+ }
+
+ public ThreadFactory getThreadFactory() {
+ return _threadFactory;
+ }
- private String _endpoint = "https://sdk.split.io";
+ public HashSet getSetsFilter() {
+ return _flagSetsFilter;
+ }
+
+ public int getInvalidSets() {
+ return _invalidSets;
+ }
+
+ public CustomHeaderDecorator customHeaderDecorator() {
+ return _customHeaderDecorator;
+ }
+
+ public boolean isSdkEndpointOverridden() {
+ return !_endpoint.equals(SDK_ENDPOINT);
+ }
+
+ public CustomHttpModule alternativeHTTPModule() { return _alternativeHTTPModule; }
+
+ public FallbackTreatmentsConfiguration fallbackTreatments() { return _fallbackTreatments; }
+
+ public static final class Builder {
+ private String _endpoint = SDK_ENDPOINT;
private boolean _endpointSet = false;
- private String _eventsEndpoint = "https://events.split.io";
+ private String _eventsEndpoint = EVENTS_ENDPOINT;
private boolean _eventsEndpointSet = false;
private int _featuresRefreshRate = 60;
private int _segmentsRefreshRate = 60;
@@ -261,28 +458,53 @@ public static final class Builder {
private ImpressionsManager.Mode _impressionsMode = ImpressionsManager.Mode.OPTIMIZED;
private int _connectionTimeout = 15000;
private int _readTimeout = 15000;
- private int _numThreadsForSegmentFetch = 2;
+ private int _numThreadsForSegmentFetch = 10;
private boolean _debugEnabled = false;
private int _ready = -1; // -1 means no blocking
private int _metricsRefreshRate = 60;
private boolean _labelsEnabled = true;
- private boolean _ipAddressEnabled = true;
+ private boolean _ipAddressEnabled = true;
+ private boolean _localhostRefreshEnable = false;
private int _waitBeforeShutdown = 5000;
private String _proxyHost = "localhost";
private int _proxyPort = -1;
private String _proxyUsername;
private String _proxyPassword;
+ private ProxyConfiguration _proxyConfiguration;
private int _eventsQueueSize = 500;
- private long _eventFlushIntervalInMillis = 30 * 1000;
+ private long _eventSendIntervalInMillis = 30 * (long)1000;
private int _maxStringLength = 250;
private boolean _destroyOnShutDown = true;
private String _splitFile = null;
+ private FileTypeEnum _fileType = null;
+ private InputStream _inputStream = null;
+ private String _segmentDirectory = null;
private IntegrationsConfig _integrationsConfig = null;
private boolean _streamingEnabled = true;
private int _authRetryBackoffBase = 1;
private int _streamingReconnectBackoffBase = 1;
- private String _authServiceURL = "https://auth.split.io/api/auth";
- private String _streamingServiceURL = "https://streaming.split.io/sse";
+ private String _authServiceURL = AUTH_ENDPOINT;
+ private String _streamingServiceURL = STREAMING_ENDPOINT;
+ private String _telemetryURl = TELEMETRY_ENDPOINT;
+ private int _telemetryRefreshRate = 600;
+ private final int _uniqueKeysRefreshRateInMemory = 900;
+ private final int _uniqueKeysRefreshRateRedis = 300;
+ private final int _filterUniqueKeysRefreshRate = 86400;
+ private int _onDemandFetchRetryDelayMs = 50;
+ private final int _onDemandFetchMaxRetries = 10;
+ private final int _failedAttemptsBeforeLogging = 10;
+ private OperationMode _operationMode = OperationMode.STANDALONE;
+ private long _validateAfterInactivityInMillis = 1000;
+ private static final long STARTING_SYNC_CALL_BACKOFF_BASE_MS = 1000; //backoff base starting at 1 seconds
+ private CustomStorageWrapper _customStorageWrapper;
+ private StorageMode _storageMode = StorageMode.MEMORY;
+ private final long _lastSeenCacheSize = 500000;
+ private ThreadFactory _threadFactory;
+ private HashSet _flagSetsFilter = new HashSet<>();
+ private int _invalidSetsCount = 0;
+ private CustomHeaderDecorator _customHeaderDecorator = null;
+ private CustomHttpModule _alternativeHTTPModule = null;
+ private FallbackTreatmentsConfiguration _fallbackTreatments;
public Builder() {
}
@@ -322,7 +544,7 @@ public Builder eventsQueueSize(int eventsQueueSize) {
* @return this builder
*/
public Builder eventFlushIntervalInMillis(long eventFlushIntervalInMillis) {
- _eventFlushIntervalInMillis = eventFlushIntervalInMillis;
+ _eventSendIntervalInMillis = eventFlushIntervalInMillis;
return this;
}
@@ -542,10 +764,14 @@ public Builder waitBeforeShutdown(int waitTime) {
/**
* The host location of the proxy. Default is localhost.
+ * @deprecated
+ * This method is deprecated.
+ * Use {@link ProxyConfiguration)} instead.
*
* @param proxyHost location of the proxy
* @return this builder
*/
+ @Deprecated
public Builder proxyHost(String proxyHost) {
_proxyHost = proxyHost;
return this;
@@ -553,10 +779,14 @@ public Builder proxyHost(String proxyHost) {
/**
* The port of the proxy. Default is -1.
+ * @deprecated
+ * This method is deprecated.
+ *
Use {@link ProxyConfiguration)} instead.
*
* @param proxyPort port for the proxy
* @return this builder
*/
+ @Deprecated
public Builder proxyPort(int proxyPort) {
_proxyPort = proxyPort;
return this;
@@ -564,10 +794,14 @@ public Builder proxyPort(int proxyPort) {
/**
* Set the username for authentication against the proxy (if proxy settings are enabled). (Optional).
+ * @deprecated
+ * This method is deprecated.
+ *
Use {@link ProxyConfiguration)} instead.
*
* @param proxyUsername
* @return this builder
*/
+ @Deprecated
public Builder proxyUsername(String proxyUsername) {
_proxyUsername = proxyUsername;
return this;
@@ -584,6 +818,17 @@ public Builder proxyPassword(String proxyPassword) {
return this;
}
+ /**
+ * Set the mtls authentication against the proxy (if proxy settings are enabled). (Optional).
+ *
+ * @param proxyConfiguration
+ * @return this builder
+ */
+ public Builder proxyConfiguration(ProxyConfiguration proxyConfiguration) {
+ _proxyConfiguration = proxyConfiguration;
+ return this;
+ }
+
/**
* Disables running destroy() on shutdown by default.
*
@@ -614,6 +859,24 @@ public Builder splitFile(String splitFile) {
return this;
}
+ public Builder splitFile(InputStream inputStream, FileTypeEnum fileType) {
+ _fileType = fileType;
+ _inputStream = inputStream;
+ return this;
+ }
+
+ /**
+ * Set the location of the directory where are the segment json files for localhost mode.
+ * This setting is optional.
+ *
+ * @param sementDirectory location
+ * @return this builder
+ */
+ public Builder segmentDirectory(String sementDirectory){
+ _segmentDirectory = sementDirectory;
+ return this;
+ }
+
/**
* Sets up integrations for the Split SDK (Currently Impressions outgoing integrations supported only).
* @param config
@@ -634,6 +897,16 @@ public Builder streamingEnabled(boolean streamingEnabled) {
return this;
}
+ /**
+ * Set if refresh is enabled or not for localhost mode. Default is false.
+ * @param localhostRefreshEnable
+ * @return
+ */
+ public Builder localhostRefreshEnable(boolean localhostRefreshEnable) {
+ _localhostRefreshEnable = localhostRefreshEnable;
+ return this;
+ }
+
/**
* Set how many seconds to wait before re attempting to authenticate for push notifications. Default 1 second. Minimum 1 second.
* @param authRetryBackoffBase
@@ -674,7 +947,115 @@ public Builder streamingServiceURL(String streamingServiceURL) {
return this;
}
- public SplitClientConfig build() {
+ /** Set telemetry service URL.
+ * @param telemetryURL
+ * @return
+ */
+ public Builder telemetryURL(String telemetryURL) {
+ _telemetryURl = telemetryURL;
+ return this;
+ }
+
+ /**
+ * How often send telemetry data
+ *
+ * @param telemetryRefreshRate
+ * @return this builder
+ */
+ public Builder telemetryRefreshRate(int telemetryRefreshRate) {
+ _telemetryRefreshRate = telemetryRefreshRate;
+ return this;
+ }
+
+ /**
+ * Type of storage
+ *
+ * @param mode
+ * @return this builder
+ */
+ public Builder operationMode(OperationMode mode) {
+ _operationMode = mode;
+ return this;
+ }
+
+ /**
+ *
+ * @param mode
+ * @return this builder
+ */
+ public Builder storageMode(StorageMode mode) {
+ _storageMode = mode;
+ return this;
+ }
+
+ /**
+ * Storage wrapper
+ *
+ * @param customStorageWrapper
+ * @return this builder
+ */
+ public Builder customStorageWrapper(CustomStorageWrapper customStorageWrapper) {
+ _customStorageWrapper = customStorageWrapper;
+ return this;
+ }
+
+ /**
+ * Flag Sets Filter
+ *
+ * @param flagSetsFilter
+ * @return this builder
+ */
+ public Builder flagSetsFilter(List flagSetsFilter) {
+ _flagSetsFilter = new LinkedHashSet<>(cleanup(flagSetsFilter));
+ _invalidSetsCount = flagSetsFilter.size() - _flagSetsFilter.size();
+ return this;
+ }
+
+ /**
+ * User Custom Header Decorator
+ *
+ * @param customHeaderDecorator
+ * @return this builder
+ */
+ public Builder customHeaderDecorator(CustomHeaderDecorator customHeaderDecorator) {
+ _customHeaderDecorator = customHeaderDecorator;
+ return this;
+ }
+
+ /**
+ * Alternative Http Client
+ *
+ * @param alternativeHTTPModule
+ * @return this builder
+ */
+ public Builder alternativeHTTPModule(CustomHttpModule alternativeHTTPModule) {
+ _alternativeHTTPModule = alternativeHTTPModule;
+ return this;
+ }
+
+ /**
+ * Fallback Treatments
+ *
+ * @param fallbackTreatments
+ * @return this builder
+ */
+ public Builder fallbackTreatments(FallbackTreatmentsConfiguration fallbackTreatments) {
+ _fallbackTreatments = fallbackTreatments;
+ return this;
+ }
+
+ /**
+ * Thread Factory
+ *
+ * @param threadFactory
+ * @return this builder
+ */
+ public Builder threadFactory(ThreadFactory threadFactory) {
+ _threadFactory = threadFactory;
+ return this;
+ }
+
+ private void verifyRates() {
if (_featuresRefreshRate < 5 ) {
throw new IllegalArgumentException("featuresRefreshRate must be >= 5: " + _featuresRefreshRate);
}
@@ -683,6 +1064,46 @@ public SplitClientConfig build() {
throw new IllegalArgumentException("segmentsRefreshRate must be >= 30: " + _segmentsRefreshRate);
}
+ if (_eventSendIntervalInMillis < 1000) {
+ throw new IllegalArgumentException("_eventSendIntervalInMillis must be >= 1000: " + _eventSendIntervalInMillis);
+ }
+
+ if (_metricsRefreshRate < 30) {
+ throw new IllegalArgumentException("metricsRefreshRate must be >= 30: " + _metricsRefreshRate);
+ }
+
+ if(_telemetryRefreshRate < 60) {
+ throw new IllegalStateException("_telemetryRefreshRate must be >= 60");
+ }
+ }
+
+ private void verifyEndPoints() {
+ if (_endpoint == null) {
+ throw new IllegalArgumentException("endpoint must not be null");
+ }
+
+ if (_eventsEndpoint == null) {
+ throw new IllegalArgumentException("events endpoint must not be null");
+ }
+
+ if (_endpointSet && !_eventsEndpointSet) {
+ throw new IllegalArgumentException("If endpoint is set, you must also set the events endpoint");
+ }
+
+ if (_authServiceURL == null) {
+ throw new IllegalArgumentException("authServiceURL must not be null");
+ }
+
+ if (_streamingServiceURL == null) {
+ throw new IllegalArgumentException("streamingServiceURL must not be null");
+ }
+
+ if (_telemetryURl == null) {
+ throw new IllegalArgumentException("telemetryURl must not be null");
+ }
+ }
+
+ private void verifyAllModes() {
switch (_impressionsMode) {
case OPTIMIZED:
_impressionsRefreshRate = (_impressionsRefreshRate <= 0) ? 300 : Math.max(60, _impressionsRefreshRate);
@@ -690,20 +1111,26 @@ public SplitClientConfig build() {
case DEBUG:
_impressionsRefreshRate = (_impressionsRefreshRate <= 0) ? 60 : _impressionsRefreshRate;
break;
+ case NONE:
+ break;
}
- if (_eventFlushIntervalInMillis < 1000) {
- throw new IllegalArgumentException("_eventFlushIntervalInMillis must be >= 1000: " + _eventFlushIntervalInMillis);
+ if (_impressionsQueueSize <=0 ) {
+ throw new IllegalArgumentException("impressionsQueueSize must be > 0: " + _impressionsQueueSize);
}
-
- if (_metricsRefreshRate < 30) {
- throw new IllegalArgumentException("metricsRefreshRate must be >= 30: " + _metricsRefreshRate);
+ if(_storageMode == null) {
+ _storageMode = StorageMode.MEMORY;
}
- if (_impressionsQueueSize <=0 ) {
- throw new IllegalArgumentException("impressionsQueueSize must be > 0: " + _impressionsQueueSize);
+ if(OperationMode.CONSUMER.equals(_operationMode)){
+ if(_customStorageWrapper == null) {
+ throw new IllegalStateException("Custom Storage must not be null on Consumer mode.");
+ }
+ _storageMode = StorageMode.PLUGGABLE;
}
+ }
+ private void verifyNetworkParams() {
if (_connectionTimeout <= 0) {
throw new IllegalArgumentException("connectionTimeOutInMs must be > 0: " + _connectionTimeout);
}
@@ -711,40 +1138,89 @@ public SplitClientConfig build() {
if (_readTimeout <= 0) {
throw new IllegalArgumentException("readTimeout must be > 0: " + _readTimeout);
}
+ if (_authRetryBackoffBase <= 0) {
+ throw new IllegalArgumentException("authRetryBackoffBase: must be >= 1");
+ }
- if (_endpoint == null) {
- throw new IllegalArgumentException("endpoint must not be null");
+ if (_streamingReconnectBackoffBase <= 0) {
+ throw new IllegalArgumentException("streamingReconnectBackoffBase: must be >= 1");
}
- if (_eventsEndpoint == null) {
- throw new IllegalArgumentException("events endpoint must not be null");
+ if (_onDemandFetchRetryDelayMs <= 0) {
+ throw new IllegalStateException("streamingRetryDelay must be > 0");
}
- if (_endpointSet && !_eventsEndpointSet) {
- throw new IllegalArgumentException("If endpoint is set, you must also set the events endpoint");
+ if(_onDemandFetchMaxRetries <= 0) {
+ throw new IllegalStateException("_onDemandFetchMaxRetries must be > 0");
}
+ }
- if (_numThreadsForSegmentFetch <= 0) {
- throw new IllegalArgumentException("Number of threads for fetching segments MUST be greater than zero");
+ private void verifyAlternativeClient() {
+ if (_alternativeHTTPModule != null && _streamingEnabled) {
+ throw new IllegalArgumentException("Streaming feature is not supported with Alternative HTTP Client");
}
+ }
- if (_authRetryBackoffBase <= 0) {
- throw new IllegalArgumentException("authRetryBackoffBase: must be >= 1");
+ private void verifyProxy() {
+ if (_proxyConfiguration == null)
+ return;
+
+ if (_proxyPort != -1) {
+ _log.warn("Both the deprecated proxy configuration methods (`proxyHost`, `proxyPort`, `proxyUsername`, or `proxyPassword`) " +
+ "and the new `ProxyConfiguration` builder are being used. `ProxyConfiguration` will take precedence.");
}
- if (_streamingReconnectBackoffBase <= 0) {
- throw new IllegalArgumentException("streamingReconnectBackoffBase: must be >= 1");
+ if (!(_proxyConfiguration.getHost().getSchemeName().equals(HttpScheme.HTTP) ||
+ _proxyConfiguration.getHost().getSchemeName().equals(HttpScheme.HTTPS))) {
+ throw new IllegalArgumentException("Proxy scheme must be either http or https.");
}
- if (_authServiceURL == null) {
- throw new IllegalArgumentException("authServiceURL must not be null");
+ if ((_proxyConfiguration.getP12File() != null && _proxyConfiguration.getPassKey() == null) ||
+ (_proxyConfiguration.getP12File() == null && _proxyConfiguration.getPassKey() != null)) {
+ throw new IllegalArgumentException("Proxy mTLS must have p12 file path and name, and pass phrase.");
}
+ }
- if (_streamingServiceURL == null) {
- throw new IllegalArgumentException("streamingServiceURL must not be null");
+ private void verifyFallbackTreatments() {
+ if (_fallbackTreatments == null)
+ return;
+
+ FallbackTreatment processedGlobalFallbackTreatment = _fallbackTreatments.getGlobalFallbackTreatment();
+ Map processedByFlagFallbackTreatment = _fallbackTreatments.getByFlagFallbackTreatment();
+
+ if (_fallbackTreatments.getGlobalFallbackTreatment() != null) {
+ processedGlobalFallbackTreatment = new FallbackTreatment(
+ isValidTreatment(_fallbackTreatments.getGlobalFallbackTreatment().getTreatment(), "Fallback treatments"),
+ _fallbackTreatments.getGlobalFallbackTreatment().getConfig());
+ }
+
+ if (_fallbackTreatments.getByFlagFallbackTreatment() != null) {
+ processedByFlagFallbackTreatment = isValidByFlagTreatment(_fallbackTreatments.getByFlagFallbackTreatment(), "config");
+ }
+ _fallbackTreatments = new FallbackTreatmentsConfiguration(processedGlobalFallbackTreatment, processedByFlagFallbackTreatment);
+ }
+
+ public SplitClientConfig build() {
+
+ verifyRates();
+
+ verifyAllModes();
+
+ verifyEndPoints();
+
+ verifyNetworkParams();
+
+ verifyAlternativeClient();
+
+ verifyProxy();
+
+ verifyFallbackTreatments();
+
+ if (_numThreadsForSegmentFetch <= 0) {
+ throw new IllegalArgumentException("Number of threads for fetching segments MUST be greater than zero");
}
- return new SplitClientConfig(
+ return new SplitClientConfig(
_endpoint,
_eventsEndpoint,
_featuresRefreshRate,
@@ -760,21 +1236,46 @@ public SplitClientConfig build() {
_debugEnabled,
_labelsEnabled,
_ipAddressEnabled,
+ _localhostRefreshEnable,
_waitBeforeShutdown,
proxy(),
_proxyUsername,
_proxyPassword,
+ _proxyConfiguration,
_eventsQueueSize,
- _eventFlushIntervalInMillis,
+ _eventSendIntervalInMillis,
_maxStringLength,
_destroyOnShutDown,
_splitFile,
+ _fileType,
+ _inputStream,
+ _segmentDirectory,
_integrationsConfig,
_streamingEnabled,
_authRetryBackoffBase,
_streamingReconnectBackoffBase,
_authServiceURL,
- _streamingServiceURL);
+ _streamingServiceURL,
+ _telemetryURl,
+ _telemetryRefreshRate,
+ _onDemandFetchRetryDelayMs,
+ _onDemandFetchMaxRetries,
+ _failedAttemptsBeforeLogging,
+ _operationMode,
+ _validateAfterInactivityInMillis,
+ STARTING_SYNC_CALL_BACKOFF_BASE_MS,
+ _customStorageWrapper,
+ _storageMode,
+ _uniqueKeysRefreshRateInMemory,
+ _uniqueKeysRefreshRateRedis,
+ _filterUniqueKeysRefreshRate,
+ _lastSeenCacheSize,
+ _threadFactory,
+ _flagSetsFilter,
+ _invalidSetsCount,
+ _customHeaderDecorator,
+ _alternativeHTTPModule,
+ _fallbackTreatments);
}
}
-}
+}
\ No newline at end of file
diff --git a/client/src/main/java/io/split/client/SplitClientImpl.java b/client/src/main/java/io/split/client/SplitClientImpl.java
index 7792f5a1..2c55729a 100644
--- a/client/src/main/java/io/split/client/SplitClientImpl.java
+++ b/client/src/main/java/io/split/client/SplitClientImpl.java
@@ -1,31 +1,48 @@
package io.split.client;
-import io.split.cache.SplitCache;
+import com.google.gson.GsonBuilder;
import io.split.client.api.Key;
+import io.split.client.api.SdkEvent;
+import io.split.client.api.SdkEventListener;
import io.split.client.api.SplitResult;
-import io.split.client.dtos.Event;
+import io.split.client.dtos.*;
+import io.split.client.events.EventsStorageProducer;
import io.split.client.impressions.Impression;
+import io.split.client.lifecycle.SdkEventsManager;
+import io.split.client.lifecycle.SdkInternalEvent;
import io.split.client.impressions.ImpressionsManager;
+import io.split.client.interceptors.FlagSetsFilter;
import io.split.engine.SDKReadinessGates;
import io.split.engine.evaluator.Evaluator;
import io.split.engine.evaluator.EvaluatorImp;
import io.split.engine.evaluator.Labels;
-import io.split.engine.metrics.Metrics;
-import io.split.grammar.Treatments;
import io.split.inputValidation.EventsValidator;
import io.split.inputValidation.KeyValidator;
import io.split.inputValidation.SplitNameValidator;
import io.split.inputValidation.TrafficTypeValidator;
+import io.split.inputValidation.ImpressionPropertiesValidator;
+import io.split.storages.SplitCacheConsumer;
+import io.split.telemetry.domain.enums.MethodEnum;
+import io.split.telemetry.storage.TelemetryConfigProducer;
+import io.split.telemetry.storage.TelemetryEvaluationProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.Set;
import java.util.concurrent.TimeoutException;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import static com.google.common.base.Preconditions.checkNotNull;
+import static io.split.inputValidation.FlagSetsValidator.cleanup;
/**
* A basic implementation of SplitClient.
@@ -33,68 +50,378 @@
* @author adil
*/
public final class SplitClientImpl implements SplitClient {
- public static final SplitResult SPLIT_RESULT_CONTROL = new SplitResult(Treatments.CONTROL, null);
-
- private static final String GET_TREATMENT = "getTreatment";
- private static final String GET_TREATMENT_WITH_CONFIG = "getTreatmentWithConfig";
+ private static final String CLIENT_DESTROY = "Client has already been destroyed - no calls possible";
+ private static final String CATCHALL_EXCEPTION = "CatchAll Exception";
+ private static final String MATCHING_KEY = "matchingKey";
private static final Logger _log = LoggerFactory.getLogger(SplitClientImpl.class);
private final SplitFactory _container;
- private final SplitCache _splitCache;
+ private final SdkEventsManager _eventsManager;
+ private final SplitCacheConsumer _splitCacheConsumer;
private final ImpressionsManager _impressionManager;
- private final Metrics _metrics;
private final SplitClientConfig _config;
- private final EventClient _eventClient;
+ private final EventsStorageProducer _eventsStorageProducer;
private final SDKReadinessGates _gates;
private final Evaluator _evaluator;
+ private final TelemetryEvaluationProducer _telemetryEvaluationProducer;
+ private final TelemetryConfigProducer _telemetryConfigProducer;
+ private final FlagSetsFilter _flagSetsFilter;
+ private final FallbackTreatmentCalculator _fallbackTreatmentCalculator;
public SplitClientImpl(SplitFactory container,
- SplitCache splitCache,
+ SplitCacheConsumer splitCacheConsumer,
ImpressionsManager impressionManager,
- Metrics metrics,
- EventClient eventClient,
+ EventsStorageProducer eventsStorageProducer,
SplitClientConfig config,
SDKReadinessGates gates,
- Evaluator evaluator) {
+ Evaluator evaluator,
+ TelemetryEvaluationProducer telemetryEvaluationProducer,
+ TelemetryConfigProducer telemetryConfigProducer,
+ FlagSetsFilter flagSetsFilter,
+ FallbackTreatmentCalculator fallbackTreatmentCalculator) {
+ this(container, splitCacheConsumer, impressionManager, eventsStorageProducer, config, gates, evaluator,
+ telemetryEvaluationProducer, telemetryConfigProducer, flagSetsFilter, fallbackTreatmentCalculator, null);
+ }
+
+
+ public SplitClientImpl(SplitFactory container,
+ SplitCacheConsumer splitCacheConsumer,
+ ImpressionsManager impressionManager,
+ EventsStorageProducer eventsStorageProducer,
+ SplitClientConfig config,
+ SDKReadinessGates gates,
+ Evaluator evaluator,
+ TelemetryEvaluationProducer telemetryEvaluationProducer,
+ TelemetryConfigProducer telemetryConfigProducer,
+ FlagSetsFilter flagSetsFilter,
+ FallbackTreatmentCalculator fallbackTreatmentCalculator,
+ SdkEventsManager eventsManager) {
_container = container;
- _splitCache = checkNotNull(splitCache);
+ _eventsManager = eventsManager;
+ _splitCacheConsumer = checkNotNull(splitCacheConsumer);
_impressionManager = checkNotNull(impressionManager);
- _metrics = metrics;
- _eventClient = eventClient;
+ _eventsStorageProducer = eventsStorageProducer;
_config = config;
_gates = checkNotNull(gates);
_evaluator = checkNotNull(evaluator);
+ _telemetryEvaluationProducer = checkNotNull(telemetryEvaluationProducer);
+ _telemetryConfigProducer = checkNotNull(telemetryConfigProducer);
+ _flagSetsFilter = flagSetsFilter;
+ _fallbackTreatmentCalculator = fallbackTreatmentCalculator;
+ }
+
+ @Override
+ public String getTreatment(String key, String featureFlagName) {
+ return getTreatment(key, featureFlagName, Collections.emptyMap());
+ }
+
+ @Override
+ public String getTreatment(String key, String featureFlagName, Map attributes) {
+ return getTreatmentWithConfigInternal(key, null, featureFlagName, attributes, new EvaluationOptions(null), MethodEnum.TREATMENT).treatment();
+ }
+
+ @Override
+ public String getTreatment(Key key, String featureFlagName, Map attributes) {
+ return getTreatmentWithConfigInternal(key.matchingKey(), key.bucketingKey(), featureFlagName, attributes, new EvaluationOptions(null),
+ MethodEnum.TREATMENT).treatment();
+ }
+
+ @Override
+ public SplitResult getTreatmentWithConfig(String key, String featureFlagName) {
+ return getTreatmentWithConfigInternal(key, null, featureFlagName, Collections.emptyMap(), new EvaluationOptions(null),
+ MethodEnum.TREATMENT_WITH_CONFIG);
+ }
+
+ @Override
+ public SplitResult getTreatmentWithConfig(String key, String featureFlagName, Map attributes) {
+ return getTreatmentWithConfigInternal(key, null, featureFlagName, attributes, new EvaluationOptions(null), MethodEnum.TREATMENT_WITH_CONFIG);
+ }
+
+ @Override
+ public SplitResult getTreatmentWithConfig(Key key, String featureFlagName, Map attributes) {
+ return getTreatmentWithConfigInternal(key.matchingKey(), key.bucketingKey(), featureFlagName, attributes, new EvaluationOptions(null),
+ MethodEnum.TREATMENT_WITH_CONFIG);
+ }
+
+ @Override
+ public Map getTreatments(String key, List featureFlagNames) {
+ return getTreatments(key, featureFlagNames, Collections.emptyMap());
+ }
+
+ @Override
+ public Map getTreatments(String key, List featureFlagNames, Map attributes) {
+ return getTreatmentsWithConfigInternal(key, null, featureFlagNames, attributes, new EvaluationOptions(null), MethodEnum.TREATMENTS)
+ .entrySet().stream()
+ .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().treatment()));
+ }
+
+ @Override
+ public Map getTreatments(Key key, List featureFlagNames, Map attributes) {
+ return getTreatmentsWithConfigInternal(key.matchingKey(), key.bucketingKey(), featureFlagNames, attributes,
+ new EvaluationOptions(null), MethodEnum.TREATMENTS)
+ .entrySet().stream()
+ .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().treatment()));
+ }
+
+ @Override
+ public Map getTreatmentsWithConfig(String key, List featureFlagNames) {
+ return getTreatmentsWithConfigInternal(key, null, featureFlagNames, Collections.emptyMap(), new EvaluationOptions(null),
+ MethodEnum.TREATMENTS_WITH_CONFIG);
+ }
+
+ @Override
+ public Map getTreatmentsWithConfig(String key, List featureFlagNames, Map attributes) {
+ return getTreatmentsWithConfigInternal(key, null, featureFlagNames, attributes,
+ new EvaluationOptions(null), MethodEnum.TREATMENTS_WITH_CONFIG);
+ }
+
+ @Override
+ public Map getTreatmentsWithConfig(Key key, List featureFlagNames, Map attributes) {
+ return getTreatmentsWithConfigInternal(key.matchingKey(), key.bucketingKey(), featureFlagNames, attributes, new EvaluationOptions(null),
+ MethodEnum.TREATMENTS_WITH_CONFIG);
+ }
+
+ @Override
+ public Map getTreatmentsByFlagSet(String key, String flagSet) {
+ return getTreatmentsBySetsWithConfigInternal(key, null, new ArrayList<>(Arrays.asList(flagSet)),
+ null, new EvaluationOptions(null), MethodEnum.TREATMENTS_BY_FLAG_SET).entrySet().stream()
+ .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().treatment()));
+ }
+
+ @Override
+ public Map getTreatmentsByFlagSet(String key, String flagSet, Map attributes) {
+ return getTreatmentsBySetsWithConfigInternal(key, null, new ArrayList<>(Arrays.asList(flagSet)),
+ attributes, new EvaluationOptions(null), MethodEnum.TREATMENTS_BY_FLAG_SET).entrySet().stream()
+ .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().treatment()));
+ }
+
+ @Override
+ public Map getTreatmentsByFlagSet(Key key, String flagSet, Map attributes) {
+ return getTreatmentsBySetsWithConfigInternal(key.matchingKey(), key.bucketingKey(), new ArrayList<>(Arrays.asList(flagSet)),
+ attributes, new EvaluationOptions(null), MethodEnum.TREATMENTS_BY_FLAG_SET).entrySet().stream()
+ .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().treatment()));
+ }
+
+ @Override
+ public Map getTreatmentsByFlagSets(String key, List flagSets) {
+ return getTreatmentsBySetsWithConfigInternal(key, null, flagSets,
+ null, new EvaluationOptions(null), MethodEnum.TREATMENTS_BY_FLAG_SETS).entrySet().stream()
+ .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().treatment()));
+ }
+
+ @Override
+ public Map getTreatmentsByFlagSets(String key, List flagSets, Map attributes) {
+ return getTreatmentsBySetsWithConfigInternal(key, null, flagSets,
+ attributes, new EvaluationOptions(null), MethodEnum.TREATMENTS_BY_FLAG_SETS).entrySet().stream()
+ .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().treatment()));
+ }
+
+ @Override
+ public Map getTreatmentsByFlagSets(Key key, List flagSets, Map attributes) {
+ return getTreatmentsBySetsWithConfigInternal(key.matchingKey(), key.bucketingKey(), flagSets,
+ attributes, new EvaluationOptions(null), MethodEnum.TREATMENTS_BY_FLAG_SETS).entrySet().stream()
+ .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().treatment()));
+ }
+
+ @Override
+ public Map getTreatmentsWithConfigByFlagSet(String key, String flagSet) {
+ return getTreatmentsBySetsWithConfigInternal(key, null, new ArrayList<>(Arrays.asList(flagSet)),
+ null, new EvaluationOptions(null), MethodEnum.TREATMENTS_WITH_CONFIG_BY_FLAG_SET);
+ }
+
+ @Override
+ public Map getTreatmentsWithConfigByFlagSet(String key, String flagSet, Map attributes) {
+ return getTreatmentsBySetsWithConfigInternal(key, null, new ArrayList<>(Arrays.asList(flagSet)),
+ attributes, new EvaluationOptions(null), MethodEnum.TREATMENTS_WITH_CONFIG_BY_FLAG_SET);
+ }
+
+ @Override
+ public Map getTreatmentsWithConfigByFlagSet(Key key, String flagSet, Map attributes) {
+ return getTreatmentsBySetsWithConfigInternal(key.matchingKey(), key.bucketingKey(), new ArrayList<>(Arrays.asList(flagSet)),
+ attributes, new EvaluationOptions(null), MethodEnum.TREATMENTS_WITH_CONFIG_BY_FLAG_SET);
+ }
+
+ @Override
+ public Map getTreatmentsWithConfigByFlagSets(String key, List flagSets) {
+ return getTreatmentsBySetsWithConfigInternal(key, null, flagSets,
+ null, new EvaluationOptions(null), MethodEnum.TREATMENTS_WITH_CONFIG_BY_FLAG_SETS);
+ }
+
+ @Override
+ public Map getTreatmentsWithConfigByFlagSets(String key, List flagSets, Map attributes) {
+ return getTreatmentsBySetsWithConfigInternal(key, null, flagSets,
+ attributes, new EvaluationOptions(null), MethodEnum.TREATMENTS_WITH_CONFIG_BY_FLAG_SETS);
+ }
+
+ @Override
+ public Map getTreatmentsWithConfigByFlagSets(Key key, List flagSets, Map attributes) {
+ return getTreatmentsBySetsWithConfigInternal(key.matchingKey(), key.bucketingKey(), flagSets,
+ attributes, new EvaluationOptions(null), MethodEnum.TREATMENTS_WITH_CONFIG_BY_FLAG_SETS);
+ }
+
+ @Override
+ public String getTreatment(String key, String featureFlagName, EvaluationOptions evaluationOptions) {
+ return getTreatment(key, featureFlagName, Collections.emptyMap(), evaluationOptions);
+ }
+
+ @Override
+ public String getTreatment(String key, String featureFlagName, Map attributes, EvaluationOptions evaluationOptions) {
+ return getTreatmentWithConfigInternal(key, null, featureFlagName, attributes, evaluationOptions, MethodEnum.TREATMENT).treatment();
+ }
+
+ @Override
+ public String getTreatment(Key key, String featureFlagName, Map attributes, EvaluationOptions evaluationOptions) {
+ return getTreatmentWithConfigInternal(key.matchingKey(), key.bucketingKey(), featureFlagName, attributes, evaluationOptions,
+ MethodEnum.TREATMENT).treatment();
+ }
+
+ @Override
+ public Map getTreatments(String key, List featureFlagNames,
+ EvaluationOptions evaluationOptions) {
+ return getTreatments(key, featureFlagNames, Collections.emptyMap(), evaluationOptions);
+ }
+
+ @Override
+ public Map getTreatments(String key, List featureFlagNames, Map attributes,
+ EvaluationOptions evaluationOptions) {
+ return getTreatmentsWithConfigInternal(key, null, featureFlagNames, attributes, evaluationOptions, MethodEnum.TREATMENTS)
+ .entrySet().stream()
+ .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().treatment()));
+ }
+
+ @Override
+ public Map getTreatments(Key key, List featureFlagNames, Map attributes,
+ EvaluationOptions evaluationOptions) {
+ return getTreatmentsWithConfigInternal(key.matchingKey(), key.bucketingKey(), featureFlagNames, attributes, evaluationOptions,
+ MethodEnum.TREATMENTS)
+ .entrySet().stream()
+ .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().treatment()));
+ }
+
+ @Override
+ public SplitResult getTreatmentWithConfig(String key, String featureFlagName, EvaluationOptions evaluationOptions) {
+ return getTreatmentWithConfigInternal(key, null, featureFlagName, Collections.emptyMap(), evaluationOptions,
+ MethodEnum.TREATMENT_WITH_CONFIG);
+ }
+
+ @Override
+ public SplitResult getTreatmentWithConfig(Key key, String featureFlagName, Map attributes,
+ EvaluationOptions evaluationOptions) {
+ return getTreatmentWithConfigInternal(key.matchingKey(), key.bucketingKey(), featureFlagName, attributes, evaluationOptions,
+ MethodEnum.TREATMENT_WITH_CONFIG);
+ }
+
+ @Override
+ public SplitResult getTreatmentWithConfig(String key, String featureFlagName, Map attributes,
+ EvaluationOptions evaluationOptions) {
+ return getTreatmentWithConfigInternal(key, null, featureFlagName, attributes, evaluationOptions,
+ MethodEnum.TREATMENT_WITH_CONFIG);
+ }
+
+ @Override
+ public Map getTreatmentsWithConfig(String key, List featureFlagNames, Map attributes,
+ EvaluationOptions evaluationOptions) {
+ return getTreatmentsWithConfigInternal(key, null, featureFlagNames, attributes, evaluationOptions,
+ MethodEnum.TREATMENTS_WITH_CONFIG);
+ }
+
+ @Override
+ public Map