Class ConnectionModeBuilder

java.lang.Object
com.launchdarkly.sdk.android.integrations.ConnectionModeBuilder

public class ConnectionModeBuilder extends Object
Configures the data pipeline (initializers and synchronizers) for a single ConnectionMode.

This class is not stable, and not subject to any backwards compatibility guarantees or semantic versioning. It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode

Initializers are one-shot data sources that run in order at startup to obtain an initial set of feature flag data. The SDK tries each initializer in sequence until one succeeds.

Synchronizers are long-lived data sources that keep the feature flag data up to date after initialization. The SDK uses the first synchronizer and falls back to subsequent ones if it encounters errors.

The FDv1 fallback synchronizer is an FDv1 polling synchronizer that the SDK switches to when LaunchDarkly directs it to fall back to FDv1. A customized mode keeps the SDK's default FDv1 fallback for that mode unless you configure it with fdv1FallbackSynchronizer(FDv1FallbackSynchronizerEntry) or remove it with disableFdv1Fallback().

Obtain an instance from DataSystemComponents.customMode(), configure it, and pass it to DataSystemBuilder.customizeConnectionMode(ConnectionMode, ConnectionModeBuilder):


     DataSystemComponents.customMode()
         .initializers(DataSystemComponents.pollingInitializer())
         .synchronizers(
             DataSystemComponents.streamingSynchronizer(),
             DataSystemComponents.pollingSynchronizer())
 
See Also:
  • Constructor Details

    • ConnectionModeBuilder

      public ConnectionModeBuilder()
  • Method Details

    • initializers

      @SafeVarargs public final ConnectionModeBuilder initializers(@NonNull InitializerEntry... initializers)
      Sets the initializers for this connection mode.

      Initializers run in order. The SDK advances to the next initializer if one fails or returns partial data. Any previously configured initializers are replaced.

      Use factory methods in DataSystemComponents to obtain entry instances:

      
           builder.initializers(DataSystemComponents.pollingInitializer())
       
      Parameters:
      initializers - the initializer entries, in priority order
      Returns:
      this builder
    • synchronizers

      @SafeVarargs public final ConnectionModeBuilder synchronizers(@NonNull SynchronizerEntry... synchronizers)
      Sets the synchronizers for this connection mode.

      Synchronizers keep data up to date after initialization. The SDK uses the first synchronizer and falls back to subsequent ones on error. Any previously configured synchronizers are replaced.

      Use factory methods in DataSystemComponents to obtain entry instances:

      
           builder.synchronizers(
               DataSystemComponents.streamingSynchronizer(),
               DataSystemComponents.pollingSynchronizer())
       
      Parameters:
      synchronizers - the synchronizer entries, in priority order
      Returns:
      this builder
    • fdv1FallbackSynchronizer

      public ConnectionModeBuilder fdv1FallbackSynchronizer(@NonNull FDv1FallbackSynchronizerEntry fdv1FallbackSynchronizer)
      Configures the FDv1 fallback synchronizer for this connection mode, replacing the SDK's default for the mode. This undoes any earlier call to disableFdv1Fallback().

      Use DataSystemComponents.fdv1FallbackSynchronizer() to obtain an entry:

      
           builder.fdv1FallbackSynchronizer(
               DataSystemComponents.fdv1FallbackSynchronizer()
                   .pollIntervalMillis(600_000))
       
      Parameters:
      fdv1FallbackSynchronizer - the FDv1 fallback synchronizer entry
      Returns:
      this builder
    • disableFdv1Fallback

      public ConnectionModeBuilder disableFdv1Fallback()
      Removes the FDv1 fallback synchronizer from this connection mode, so the SDK does not fall back to FDv1 in this mode. This undoes any earlier call to fdv1FallbackSynchronizer(FDv1FallbackSynchronizerEntry).

      If you neither call this method nor configure an FDv1 fallback synchronizer, the mode keeps the SDK's default FDv1 fallback.

      Returns:
      this builder
    • getInitializerEntries

      @NonNull public List<InitializerEntry> getInitializerEntries()
      Returns the configured initializer entries as an unmodifiable list.
      Returns:
      the initializer entries
    • getSynchronizerEntries

      @NonNull public List<SynchronizerEntry> getSynchronizerEntries()
      Returns the configured synchronizer entries as an unmodifiable list.
      Returns:
      the synchronizer entries
    • getFdv1FallbackSynchronizerEntry

      @Nullable public FDv1FallbackSynchronizerEntry getFdv1FallbackSynchronizerEntry()
      Returns the configured FDv1 fallback synchronizer entry, or null if none was configured.
      Returns:
      the FDv1 fallback synchronizer entry, or null
    • isFdv1FallbackDisabled

      public boolean isFdv1FallbackDisabled()
      Returns true if disableFdv1Fallback() removed the FDv1 fallback from this mode.
      Returns:
      true if the FDv1 fallback is disabled for this mode