Constructor
# new HttpDispatcher()
Bridges a Dispatch to an HttpAdapter by opening a
ServerEventConnector that listens on the adapter's events endpoint and
forwards each received event to the registered observers. In subscription mode it
also syncs the locally observed topics by subscribing/unsubscribing with the SSE
server, correlating each client through a x-correlation-id header
(DecafHeaders.CORRELATION_ID) so the server can scope subscriptions and
enforce a single connection per client.
HTTP dispatch that streams adapter events over Server-Sent Events
sequenceDiagram
participant Dispatch as HttpDispatcher
participant Adapter as HttpAdapter
participant Connector as ServerEventConnector
participant SSE as for-nest SSE server
Dispatch->>Dispatch: initialize()
Dispatch->>Adapter: startListening()
Dispatch->>Dispatch: ensureCorrelationId()
alt subscription mode
Dispatch->>Dispatch: syncSubscriptions(true)
Dispatch->>SSE: POST subscribe { topics } (x-correlation-id)
end
Dispatch->>Connector: ServerEventConnector.open(url)
Connector-->>Dispatch: event
Dispatch->>Adapter: updateObservers(table, operation, id, ...)
Dispatch->>SSE: POST unsubscribe on close()
Extends
- Dispatch