Skip to content

feat: add provider eventing support - #1

Open
jbovet wants to merge 3 commits into
mainfrom
feat-event-support
Open

jbovet wants to merge 3 commits into
mainfrom
feat-event-support

Conversation

@jbovet

@jbovet jbovet commented Aug 3, 2026

Copy link
Copy Markdown
Owner

This PR

Adds provider eventing support to the Rust SDK specification.

What's included

  • Event handlers at both the API level (OpenFeature::add_handler, run for events from any provider) and the client level (Client::add_handler, run only for the provider bound to that client's domain). Each returns an EventHandlerId for removal via remove_handler.
  • Provider event types: PROVIDER_READY, PROVIDER_ERROR, PROVIDER_STALE, PROVIDER_CONFIGURATION_CHANGED, with an EventDetails payload (provider name, message, error code, changed flags, metadata).
  • SDK-tracked provider status, queryable via OpenFeature::provider_status, OpenFeature::named_provider_status, and Client::provider_status. Status is derived from initialization outcome and emitted events.
  • EventEmitter handle, passed to providers via the new FeatureProvider::attach_emitter method (called right before initialize), which providers use to signal state changes to the SDK.

Breaking changes

  • set_provider / set_named_provider now return Result<(), EvaluationError>. The provider stays registered even if initialization fails, so the error can be discarded with .ok().
  • FeatureProvider::initialize now returns Result<(), EvaluationError> (previously ()). attach_emitter is added with a default (no-op) body, so existing providers don't need to implement it. status() is deprecated — the SDK derives status from events and no longer calls it.
  • EvaluationErrorCode gains a ProviderFatal variant.
  • ProviderStatus gains a Fatal variant and STALE is renamed to Stale; it now derives Clone, Copy, Hash.

Testing

  • New spec-annotated tests in src/api/event_registry.rs covering handler registration/removal, persistence across provider changes, immediate replay, panic isolation, status transitions, PROVIDER_FATAL escalation, superseded-provider handling.
  • Existing tests updated for the new initialize/set_provider signatures.
  • New runnable examples/events.rs demonstrating an event-emitting provider.
  • cargo fmt --check, cargo clippy -- -D warnings, and the full test suite pass locally.

Docs

  • README "Eventing" section rewritten with a usage example and status-query notes.

Closes open-feature#93

@jbovet jbovet closed this Aug 3, 2026
@jbovet jbovet reopened this Aug 3, 2026
Implement the OpenFeature eventing spec (section 5): API- and
client-level event handlers, SDK-tracked provider status, and an
EventEmitter handle providers use to signal state changes.
Providers receive an EventEmitter via the new
FeatureProvider::attach_emitter method (called right before
initialize). The SDK owns the terminal PROVIDER_READY/PROVIDER_ERROR
event derived from the initialization outcome, so events emitted during
initialize are ignored and readiness handlers fire exactly once.
Handlers registered after a provider is already in the associated state
run immediately (5.3.3), panicking handlers are isolated (5.2.5), and
events from a superseded provider are dropped via activity tokens.

Signed-off-by: Jose Bovet Derpich <jose.bovet@gmail.com>
Signed-off-by: Jose Bovet Derpich <jose.bovet@gmail.com>
Signed-off-by: Jose Bovet Derpich <jose.bovet@gmail.com>
@jbovet
jbovet force-pushed the feat-event-support branch from 74bee72 to 6b4c0a6 Compare November 20, 2026 02:05
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.

[SDK] implement events

1 participant