Skip to content

Feature: Add Feature refresh listeners#215

Open
vazarkevych wants to merge 1 commit into
mainfrom
feature/add-feature-refresh-listeners
Open

Feature: Add Feature refresh listeners#215
vazarkevych wants to merge 1 commit into
mainfrom
feature/add-feature-refresh-listeners

Conversation

@vazarkevych

Copy link
Copy Markdown
Collaborator

Feature: Feature Refresh Listeners

Summary

This update adds feature refresh listener support to the Java SDK.

Consumers can now subscribe to feature refresh events and react when feature definitions are refreshed successfully or when a refresh attempt fails. The event payload is metadata-only and does not expose feature definitions directly.

This allows SDK users to observe refresh lifecycle events, trigger custom logging or monitoring, and integrate refresh status with their own application workflows.


What Changed

Feature Refresh Listener API

Added client-level APIs for managing feature refresh listeners:

  1. addFeatureRefreshListener(...)
  2. removeFeatureRefreshListener(...)
  3. subscribeFeatureRefreshListener(...)

The subscribeFeatureRefreshListener(...) API returns a FeatureRefreshSubscription, which provides an idempotent cleanup mechanism for unsubscribing listeners.


Feature Refresh Event Metadata

Added FeatureRefreshEvent to provide metadata about feature refresh results.

Listeners can now receive events when:

  1. Feature refresh completes successfully.
  2. Feature refresh fails.
  3. Refresh metadata needs to be inspected by the consumer.

The event is intentionally metadata-only, so listener consumers can react to refresh status without directly depending on feature payload internals.


Listener Dispatch Support

Feature refresh listener dispatch is now supported across the refresh flow, including:

  1. GrowthBookClient
  2. GBFeaturesRepository
  3. NativeJavaGbFeatureRepository
  4. LocalGbFeatureRepository

This ensures refresh events are propagated consistently across client-level and repository-level refresh operations.


Listener Failure Isolation

Listener execution is isolated from the SDK refresh flow.

If a listener throws an exception:

  1. The exception does not break the feature refresh process.
  2. Other listeners can still be executed.
  3. SDK feature fetching and cache behavior remain unaffected.

This prevents consumer-side listener failures from impacting core SDK behavior.


Optional Listener Executor

Added optional executor support through:

Options.featureRefreshListenerExecutor(...)

This allows consumers to control how listener callbacks are dispatched, including custom threading or asynchronous execution strategies.


Repository Initialization Refactor

Refactored GrowthBookClient repository initialization into an internal provider.

This keeps repository creation and lifecycle handling more centralized, while preserving the public SDK behavior.


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.

1 participant