Class

EventsController

for-nest.events.EventsController(clientContext, flavours, options, registry)

Constructor

# new EventsController(clientContext, flavours, options, registry)

Registers observers against all listening adapters and streams the events they emit back to the client over SSE. A single requester (identified by fingerprint) may hold only one SSE connection: claiming a connection when one is already active throws a ConflictError. When ObserverEventsOptions.subscriptionMode is enabled, events are filtered by the requester's topic subscriptions held in the ObserverSubscriptionRegistry.

SSE controller exposing Decaf observer events as a Server-Sent Events stream

sequenceDiagram participant Client participant Controller as EventsController participant Registry as ObserverSubscriptionRegistry participant Adapters Client->>Controller: listen() Controller->>Controller: resolveFingerprint() Controller->>Registry: claimConnection(fingerprint) Registry-->>Controller: claimed loop for each adapter Controller->>Adapters: observe(observer, filter) end Adapters-->>Controller: refresh(args) Controller->>Client: SSE message Client->>Controller: disconnect Controller->>Registry: releaseConnection(fingerprint)
Parameters:
Name Type Description
clientContext DecafRequestContext

The active request context

flavours Array.<string>

The adapter flavours to observe events on (injected via LISTENING_ADAPTERS_FLAVOURS)

options ObserverEventsOptions

Observer events configuration (injected via OBSERVER_EVENTS_OPTIONS)

registry ObserverSubscriptionRegistry

The topic-subscription registry

View Source events-module/EventsController.ts, line 21