Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
d92af88
feat: Add FDv2 connection mode types and mode resolution table
aaron-zeisler Mar 9, 2026
8b8bd7e
feat: Implement switchMode() on FDv2DataSource
aaron-zeisler Mar 10, 2026
8b1af40
feat: Add FDv2DataSourceBuilder with stub configurer resolution
aaron-zeisler Mar 10, 2026
2d1b776
feat: wire real FDv2 ComponentConfigurer implementations in FDv2DataS…
aaron-zeisler Mar 10, 2026
05f9536
feat: Add FDv2 mode resolution to ConnectivityManager
aaron-zeisler Mar 10, 2026
c67b550
[SDK-1956] clean up unused code
aaron-zeisler Mar 12, 2026
8976bfb
[SDK-1956] refactor: switch to Approach 2 for FDv2 mode resolution an…
aaron-zeisler Mar 17, 2026
b160c58
[SDK-1956] refactor: ModeAware no longer extends DataSource
aaron-zeisler Mar 17, 2026
fbcf5f6
[SDK-1956] refactor: separate event processor and data source logic i…
aaron-zeisler Mar 17, 2026
4def25e
[SDK-1956] refactor: move synchronizer switching into SourceManager t…
aaron-zeisler Mar 17, 2026
e623fd6
[SDK-1956] refactor: move needsRefresh and FDv1/FDv2 branching into u…
aaron-zeisler Mar 18, 2026
422bea2
[SDK-1956] Replace internal switchMode() with teardown/rebuild at Con…
aaron-zeisler Mar 19, 2026
5473232
[SDK-1956] Address PR review feedback
aaron-zeisler Mar 20, 2026
5c6ac49
[SDK-1956] Address Bugbot findings in FDv2 code
aaron-zeisler Mar 23, 2026
9f5cb78
Merge branch 'main' into aaronz/SDK-1956/mode-resolution-and-switching
tanderson-ld Mar 24, 2026
493179a
[SDK-1956] Address PR review comments and add FDv1 safety tests
aaron-zeisler Mar 24, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
import com.launchdarkly.sdk.LDContext;
import com.launchdarkly.sdk.android.env.IEnvironmentReporter;
import com.launchdarkly.sdk.android.subsystems.ClientContext;
import com.launchdarkly.sdk.android.subsystems.HttpConfiguration;
import com.launchdarkly.sdk.android.subsystems.DataSourceUpdateSink;
import com.launchdarkly.sdk.android.subsystems.HttpConfiguration;
import com.launchdarkly.sdk.android.subsystems.TransactionalDataStore;
import com.launchdarkly.sdk.internal.events.DiagnosticStore;

import androidx.annotation.Nullable;

/**
* This package-private subclass of {@link ClientContext} contains additional non-public SDK objects
* that may be used by our internal components.
Expand All @@ -33,21 +36,42 @@ final class ClientContextImpl extends ClientContext {
private final PlatformState platformState;
private final TaskExecutor taskExecutor;
private final PersistentDataStoreWrapper.PerEnvironmentData perEnvironmentData;
@Nullable
private final TransactionalDataStore transactionalDataStore;

/** Used by FDv1 code paths that do not need a {@link TransactionalDataStore}. */
ClientContextImpl(
ClientContext base,
DiagnosticStore diagnosticStore,
FeatureFetcher fetcher,
PlatformState platformState,
TaskExecutor taskExecutor,
PersistentDataStoreWrapper.PerEnvironmentData perEnvironmentData
) {
this(base, diagnosticStore, fetcher, platformState, taskExecutor, perEnvironmentData, null);
}

/**
* Used by FDv2 code paths. The {@code transactionalDataStore} is needed by
* {@link FDv2DataSourceBuilder} to create {@link SelectorSourceFacade} instances
* that provide selector state to initializers and synchronizers.
*/
ClientContextImpl(
ClientContext base,
DiagnosticStore diagnosticStore,
FeatureFetcher fetcher,
PlatformState platformState,
TaskExecutor taskExecutor,
PersistentDataStoreWrapper.PerEnvironmentData perEnvironmentData,
@Nullable TransactionalDataStore transactionalDataStore
) {
super(base);
this.diagnosticStore = diagnosticStore;
this.fetcher = fetcher;
this.platformState = platformState;
this.taskExecutor = taskExecutor;
this.perEnvironmentData = perEnvironmentData;
this.transactionalDataStore = transactionalDataStore;
}

static ClientContextImpl fromConfig(
Expand Down Expand Up @@ -95,12 +119,30 @@ public static ClientContextImpl get(ClientContext context) {
return new ClientContextImpl(context, null, null, null, null, null);
}

/** Creates a context for FDv1 data sources that do not need a {@link TransactionalDataStore}. */
public static ClientContextImpl forDataSource(
ClientContext baseClientContext,
DataSourceUpdateSink dataSourceUpdateSink,
LDContext newEvaluationContext,
boolean newInBackground,
Boolean previouslyInBackground
) {
return forDataSource(baseClientContext, dataSourceUpdateSink, newEvaluationContext,
newInBackground, previouslyInBackground, null);
}

/**
* Creates a context for data sources, optionally including a {@link TransactionalDataStore}.
* FDv2 data sources require the store so that {@link FDv2DataSourceBuilder} can provide
* selector state to initializers and synchronizers via {@link SelectorSourceFacade}.
*/
public static ClientContextImpl forDataSource(
ClientContext baseClientContext,
DataSourceUpdateSink dataSourceUpdateSink,
LDContext newEvaluationContext,
boolean newInBackground,
Boolean previouslyInBackground,
@Nullable TransactionalDataStore transactionalDataStore
) {
ClientContextImpl baseContextImpl = ClientContextImpl.get(baseClientContext);
return new ClientContextImpl(
Expand All @@ -123,7 +165,8 @@ public static ClientContextImpl forDataSource(
baseContextImpl.getFetcher(),
baseContextImpl.getPlatformState(),
baseContextImpl.getTaskExecutor(),
baseContextImpl.getPerEnvironmentData()
baseContextImpl.getPerEnvironmentData(),
transactionalDataStore
);
}

Expand All @@ -139,7 +182,8 @@ public ClientContextImpl setEvaluationContext(LDContext context) {
this.fetcher,
this.platformState,
this.taskExecutor,
this.perEnvironmentData
this.perEnvironmentData,
this.transactionalDataStore
);
}

Expand All @@ -163,6 +207,11 @@ public PersistentDataStoreWrapper.PerEnvironmentData getPerEnvironmentData() {
return throwExceptionIfNull(perEnvironmentData);
}

@Nullable
public TransactionalDataStore getTransactionalDataStore() {
return transactionalDataStore;
}

private static <T> T throwExceptionIfNull(T o) {
if (o == null) {
throw new IllegalStateException(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.launchdarkly.sdk.android;

/**
* Enumerates the built-in FDv2 connection modes. Each mode maps to a
* {@link ModeDefinition} that specifies which initializers and synchronizers
* are active when the SDK is operating in that mode.
* <p>
* Not to be confused with {@link ConnectionInformation.ConnectionMode}, which
* is the public FDv1 enum representing the SDK's current connection state
* (e.g. POLLING, STREAMING, SET_OFFLINE). This class is an internal FDv2
* concept describing the <em>desired</em> data-acquisition pipeline.
* <p>
* This is a closed enum — custom connection modes (spec 5.3.5 TBD) are not
* supported in this release.
* <p>
* Package-private — not part of the public SDK API.
*
* @see ModeDefinition
* @see ModeResolutionTable
*/
final class ConnectionMode {

static final ConnectionMode STREAMING = new ConnectionMode("streaming");
static final ConnectionMode POLLING = new ConnectionMode("polling");
static final ConnectionMode OFFLINE = new ConnectionMode("offline");
static final ConnectionMode ONE_SHOT = new ConnectionMode("one-shot");
static final ConnectionMode BACKGROUND = new ConnectionMode("background");

private final String name;

private ConnectionMode(String name) {
this.name = name;
}

@Override
public String toString() {
return name;
}
}
Loading
Loading