Class FeatureRefreshNotifier
java.lang.Object
growthbook.sdk.java.repository.internal.FeatureRefreshNotifier
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 Summary
ConstructorsConstructorDescriptionFeatureRefreshNotifier(IntSupplier activeFeatureCountSupplier, Supplier<FeatureRefreshStrategy> refreshStrategySupplier) Creates a notifier backed by repository-specific metadata suppliers. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(FeatureRefreshListener listener) Registers a listener if it is non-null and not already registered.voidclear()Removes all registered listeners.static longelapsedMillis(long startedAtNanos) Calculates elapsed milliseconds from aSystem.nanoTime()start value.voidnotifyFailure(Throwable error, FeatureRefreshSource source, boolean featuresChanged, boolean loadedFromCache, long durationMillis) Publishes a failed refresh event.voidnotifySuccess(FeatureRefreshSource source, boolean featuresChanged, boolean loadedFromCache, long durationMillis) Publishes a successful refresh event.voidremove(FeatureRefreshListener listener) Removes a registered listener.
-
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 countrefreshStrategySupplier- supplies the repository refresh strategy
-
-
Method Details
-
add
Registers a listener if it is non-null and not already registered.- Parameters:
listener- listener to register
-
remove
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 sourcefeaturesChanged- whether feature data changedloadedFromCache- whether the successful data came from cachedurationMillis- 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 failuresource- refresh sourcefeaturesChanged- whether cache fallback changed feature dataloadedFromCache- whether cache fallback data was loadeddurationMillis- refresh duration in milliseconds
-
elapsedMillis
public static long elapsedMillis(long startedAtNanos) Calculates elapsed milliseconds from aSystem.nanoTime()start value.- Parameters:
startedAtNanos- start time fromSystem.nanoTime()- Returns:
- elapsed milliseconds
-