Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gthea committed Sep 8, 2023
1 parent 0b9f116 commit 13cae88
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 21 deletions.
14 changes: 14 additions & 0 deletions src/main/java/io/split/android/client/SplitFactoryHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;

Expand Down Expand Up @@ -427,6 +429,18 @@ Pair<Map<SplitFilter.Type, SplitFilter>, String> getFilterConfiguration(SyncConf
return new Pair<>(groupedFilters, splitsFilterQueryString);
}

@NonNull
Set<String> getConfiguredFlagSets(Map<SplitFilter.Type, SplitFilter> filters) {
Set<String> configuredFlagSets;
SplitFilter flagSetSplitFilter = filters.get(SplitFilter.Type.BY_SET);
if (flagSetSplitFilter != null) {
configuredFlagSets = new HashSet<>(flagSetSplitFilter.getValues());
} else {
configuredFlagSets = new HashSet<>();
}
return configuredFlagSets;
}

private TelemetryStorage getTelemetryStorage(boolean shouldRecordTelemetry, TelemetryStorage telemetryStorage) {
if (telemetryStorage != null) {
return telemetryStorage;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/io/split/android/client/SplitFactoryImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ public void taskExecuted(@NonNull SplitTaskExecutionInfo taskInfo) {
Pair<Map<SplitFilter.Type, SplitFilter>, String> filtersConfig = factoryHelper.getFilterConfiguration(config.syncConfig());
Map<SplitFilter.Type, SplitFilter> filters = filtersConfig.first;
String splitsFilterQueryStringFromConfig = filtersConfig.second;
Set<String> configuredFlagSets = (filters.get(SplitFilter.Type.BY_SET) != null) ? new HashSet<>(filters.get(SplitFilter.Type.BY_SET).getValues()) : new HashSet<>();

SplitApiFacade splitApiFacade = factoryHelper.buildApiFacade(
config, defaultHttpClient, splitsFilterQueryStringFromConfig);
Expand Down Expand Up @@ -271,7 +270,7 @@ public void taskExecuted(@NonNull SplitTaskExecutionInfo taskInfo) {
telemetrySynchronizer, mStorageContainer, splitTaskExecutor, splitApiFacade,
validationLogger, keyValidator, customerImpressionListener,
streamingComponents.getPushNotificationManager(), componentsRegister, workManagerWrapper,
eventsTracker, configuredFlagSets);
eventsTracker, factoryHelper.getConfiguredFlagSets(filters));
mDestroyer = new Runnable() {
public void run() {
Logger.w("Shutdown called for split");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,25 +92,7 @@ public SplitTaskFactoryImpl(@NonNull SplitClientConfig splitClientConfig,
}

mFilters = (filters == null) ? new ArrayList<>() : new ArrayList<>(filters.values());

int flagSetCount = 0;
int invalidFlagSetCount = 0;
if (filters != null && !filters.isEmpty()) {
SplitFilter bySetFilter = filters.get(SplitFilter.Type.BY_SET);
if (bySetFilter != null) {
flagSetCount = bySetFilter.getValues().size();
invalidFlagSetCount = bySetFilter.getInvalidValueCount();
}
}

mTelemetryTaskFactory = new TelemetryTaskFactoryImpl(mSplitApiFacade.getTelemetryConfigRecorder(),
mSplitApiFacade.getTelemetryStatsRecorder(),
telemetryStorage,
splitClientConfig,
mSplitsStorageContainer.getSplitsStorage(),
mSplitsStorageContainer.getMySegmentsStorageContainer(),
flagSetCount,
invalidFlagSetCount);
mTelemetryTaskFactory = initializeTelemetryTaskFactory(splitClientConfig, filters, telemetryStorage);
}

@Override
Expand Down Expand Up @@ -212,4 +194,28 @@ public TelemetryStatsRecorderTask getTelemetryStatsRecorderTask() {
public SplitInPlaceUpdateTask createSplitsUpdateTask(Split featureFlag, long since) {
return new SplitInPlaceUpdateTask(mSplitsStorageContainer.getSplitsStorage(), mSplitChangeProcessor, mEventsManager, mTelemetryRuntimeProducer, featureFlag, since);
}

@NonNull
private TelemetryTaskFactory initializeTelemetryTaskFactory(@NonNull SplitClientConfig splitClientConfig, @Nullable Map<SplitFilter.Type, SplitFilter> filters, TelemetryStorage telemetryStorage) {
final TelemetryTaskFactory mTelemetryTaskFactory;
int flagSetCount = 0;
int invalidFlagSetCount = 0;
if (filters != null && !filters.isEmpty()) {
SplitFilter bySetFilter = filters.get(SplitFilter.Type.BY_SET);
if (bySetFilter != null) {
flagSetCount = bySetFilter.getValues().size();
invalidFlagSetCount = bySetFilter.getInvalidValueCount();
}
}

mTelemetryTaskFactory = new TelemetryTaskFactoryImpl(mSplitApiFacade.getTelemetryConfigRecorder(),
mSplitApiFacade.getTelemetryStatsRecorder(),
telemetryStorage,
splitClientConfig,
mSplitsStorageContainer.getSplitsStorage(),
mSplitsStorageContainer.getMySegmentsStorageContainer(),
flagSetCount,
invalidFlagSetCount);
return mTelemetryTaskFactory;
}
}

0 comments on commit 13cae88

Please sign in to comment.