Skip to content

chore: adds initial impl of data system configuration APIs (early acc…#333

Draft
tanderson-ld wants to merge 15 commits intoaaronz/SDK-1956/mode-resolution-and-switchingfrom
ta/SDK-1837/datasystem-config
Draft

chore: adds initial impl of data system configuration APIs (early acc…#333
tanderson-ld wants to merge 15 commits intoaaronz/SDK-1956/mode-resolution-and-switchingfrom
ta/SDK-1837/datasystem-config

Conversation

@tanderson-ld
Copy link
Contributor

Need to populate this. Just throwing into draft for the moment.

aaron-zeisler and others added 15 commits March 20, 2026 13:25
Introduces the core types for FDv2 mode resolution (CONNMODE spec):
- ConnectionMode: enum for streaming, polling, offline, one-shot, background
- ModeDefinition: initializer/synchronizer lists per mode with stubbed configurers
- ModeState: platform state snapshot (foreground, networkAvailable)
- ModeResolutionEntry: condition + mode pair for resolution table entries
- ModeResolutionTable: ordered first-match-wins resolver with MOBILE default table
- ModeAware: interface for DataSources that support runtime switchMode()

All types are package-private. No changes to existing code.
Add ResolvedModeDefinition and mode-table constructors so
FDv2DataSource can look up initializer/synchronizer factories per
ConnectionMode. switchMode() tears down the current SourceManager,
builds a new one with the target mode's synchronizers (skipping
initializers per CONNMODE 2.0.1), and schedules execution on the
background executor. runSynchronizers() now takes an explicit
SourceManager parameter to prevent a race where the finally block
could close a SourceManager swapped in by a concurrent switchMode().
Introduces FDv2DataSourceBuilder, a ComponentConfigurer<DataSource> that
resolves the ModeDefinition table's ComponentConfigurers into
DataSourceFactories at build time by capturing the ClientContext. The
configurers are currently stubbed (return null); real wiring of concrete
initializer/synchronizer types will follow in a subsequent commit.
…ourceBuilder

Replace stub configurers with concrete factories that create
FDv2PollingInitializer, FDv2PollingSynchronizer, and
FDv2StreamingSynchronizer. Shared dependencies (SelectorSource,
ScheduledExecutorService) are created once per build() call; each
factory creates a fresh DefaultFDv2Requestor for lifecycle isolation.

Add FDv2 endpoint path constants to StandardEndpoints. Thread
TransactionalDataStore through ClientContextImpl and ConnectivityManager
so the builder can construct SelectorSourceFacade from ClientContext.
ConnectivityManager now detects ModeAware data sources and routes
foreground, connectivity, and force-offline state changes through
resolveAndSwitchMode() instead of the legacy teardown/rebuild cycle.
…d switching

Replace Approach 1 implementation with Approach 2, which the team
preferred for its cleaner architecture:

- ConnectivityManager owns the resolved mode table and performs
  ModeState -> ConnectionMode -> ResolvedModeDefinition lookup
- FDv2DataSource receives ResolvedModeDefinition via switchMode()
  and has no internal mode table
- FDv2DataSourceBuilder uses a unified ComponentConfigurer-based
  code path for both production and test mode tables
- ResolvedModeDefinition is a top-level class rather than an inner
  class of FDv2DataSource
- ConnectionMode is a final class with static instances instead of
  a Java enum

Made-with: Cursor
FDv2DataSource now explicitly implements both DataSource and ModeAware,
keeping the two interfaces independent.

Made-with: Cursor
…n ConnectivityManager

Extract updateEventProcessor() and handleModeStateChange() so that
event processor state (setOffline, setInBackground) is managed
independently from data source lifecycle. Both platform listeners
and setForceOffline() now route through handleModeStateChange(),
which snapshots state once and updates each subsystem separately.

Made-with: Cursor
…o prevent race condition

SourceManager now owns a switchSynchronizers() method that atomically
swaps the synchronizer list under the existing lock, eliminating the
window where two runSynchronizers() loops could push data into the
update sink concurrently. FDv2DataSource keeps a single final
SourceManager and uses an AtomicBoolean guard to ensure only one
execution loop runs at a time.

Made-with: Cursor
…pdateDataSource

handleModeStateChange() now simply updates the event processor and
delegates to updateDataSource(). The FDv2 ModeAware early-return and
FDv1 needsRefresh() check both live inside updateDataSource, keeping
the branching logic in one place.

Made-with: Cursor
…nectivityManager level

Per updated CSFDV2 spec and JS implementation, mode switching now tears
down the old data source and builds a new one rather than swapping
internal synchronizers. Delete ModeAware interface, remove switchMode()
from FDv2DataSource and switchSynchronizers() from SourceManager.
FDv2DataSourceBuilder becomes the sole owner of mode resolution via
setActiveMode()/build(), with ConnectivityManager using a
useFDv2ModeResolution flag to route FDv2 through the new path while
preserving FDv1 behavior. Implements CSFDV2 5.3.8 (retain data source
when old and new modes share the same ModeDefinition).

Made-with: Cursor
- Short-circuit forceOffline in resolveMode() so ModeState reflects actual platform state
- Match ConnectionMode string values to cross-SDK spec (lowercase, hyphenated)
- Add Javadoc to ConnectionMode, ClientContextImpl overloads, and FDv2DataSource internals
- Inline FDv2DataSourceBuilder casts in ConnectivityManager
- Restore try/finally and explanatory comments in runSynchronizers

Made-with: Cursor
* <pre><code>
* Components.dataSystem()
* .foregroundConnectionMode(ConnectionMode.POLLING)
* </code></pre>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swap this example to be the second example as it is more common than the custom polling example.

@aaron-zeisler aaron-zeisler force-pushed the aaronz/SDK-1956/mode-resolution-and-switching branch 2 times, most recently from 34c2752 to 1c78c34 Compare March 23, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants