Skip to content

[OFREP] Add SSE event stream support #366

@jonathannorris

Description

@jonathannorris

Context

ADR-0008 defines Server-Sent Events (SSE) as an optional real-time change notification mechanism for OFREP. The OpenAPI spec PR adds the corresponding eventStreams field to evaluation responses.

The OFREP provider currently does stateless per-request evaluation with no change detection. SSE support would allow the provider to receive real-time notifications when the underlying flag configuration changes and emit PROVIDER_CONFIGURATION_CHANGED events so the host application can react.

Scope

Parse the optional eventStreams array from the POST /ofrep/v1/evaluate/flags/{key} response and connect to any entries with type: "sse". On receiving a refetchEvaluation event, emit a PROVIDER_CONFIGURATION_CHANGED event.

1. Parse eventStreams and manage SSE connections (High)

  • On a successful evaluation response, check for an eventStreams array
  • For each entry with type: "sse", resolve the connection URL from either url or endpoint.origin + endpoint.requestUri
  • Ignore entries with unknown types for forward compatibility
  • Maintain a single SSE connection (deduplicate across evaluation responses returning the same URL)

2. Handle change events (High)

  • On receiving an event with data.type: "refetchEvaluation", emit PROVIDER_CONFIGURATION_CHANGED
  • On SSE connection failure, continue reconnection attempts

3. Inactivity timeout (Low)

  • Apply an effective inactivityDelaySec: client override > response value > default 120 seconds
  • On timeout, close the connection; on resume, reconnect

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions