Class FeatureRefreshNotifier

java.lang.Object
growthbook.sdk.java.repository.internal.FeatureRefreshNotifier

public final class FeatureRefreshNotifier extends Object
INTERNAL: not part of the supported API. Public only because the repository implementations live in the parent package — treat its signatures as free to change without a major version bump. Internal dispatcher for repository-level feature refresh events. Builds metadata-only refresh events and isolates listener failures from repository refresh flow.
  • Constructor Details

    • FeatureRefreshNotifier

      public FeatureRefreshNotifier(IntSupplier activeFeatureCountSupplier, Supplier<FeatureRefreshStrategy> refreshStrategySupplier)
      Creates a notifier backed by repository-specific metadata suppliers.
      Parameters:
      activeFeatureCountSupplier - supplies the current active feature count
      refreshStrategySupplier - supplies the repository refresh strategy
  • Method Details

    • add

      public void add(FeatureRefreshListener listener)
      Registers a listener if it is non-null and not already registered.
      Parameters:
      listener - listener to register
    • remove

      public void remove(FeatureRefreshListener listener)
      Removes a registered listener.
      Parameters:
      listener - listener to remove
    • clear

      public void clear()
      Removes all registered listeners. Intended for repository shutdown.
    • notifySuccess

      public void notifySuccess(FeatureRefreshSource source, boolean featuresChanged, boolean loadedFromCache, long durationMillis)
      Publishes a successful refresh event.
      Parameters:
      source - refresh source
      featuresChanged - whether feature data changed
      loadedFromCache - whether the successful data came from cache
      durationMillis - refresh duration in milliseconds
    • notifyFailure

      public void notifyFailure(Throwable error, FeatureRefreshSource source, boolean featuresChanged, boolean loadedFromCache, long durationMillis)
      Publishes a failed refresh event.
      Parameters:
      error - refresh failure
      source - refresh source
      featuresChanged - whether cache fallback changed feature data
      loadedFromCache - whether cache fallback data was loaded
      durationMillis - refresh duration in milliseconds
    • elapsedMillis

      public static long elapsedMillis(long startedAtNanos)
      Calculates elapsed milliseconds from a System.nanoTime() start value.
      Parameters:
      startedAtNanos - start time from System.nanoTime()
      Returns:
      elapsed milliseconds