Class: CdcEmitter
Defined in: src/realtime/CdcEmitter.ts:27
Change Data Capture (CDC) emitter and subscriber.
Bridges database real-time notifications (PostgreSQL LISTEN/NOTIFY, MySQL binlog triggers, MSSQL CDC) to in-process event handlers and EntityEventBus instances.
Constructors
Constructor
new CdcEmitter(
eventBus?):CdcEmitter
Defined in: src/realtime/CdcEmitter.ts:33
Parameters
| Parameter | Type |
|---|---|
eventBus? | EntityEventBus |
Returns
CdcEmitter
Methods
publish()
publish<
T>(event):Promise<void>
Defined in: src/realtime/CdcEmitter.ts:39
Publishes a Change Data Capture event to all matching subscribers and optionally bridges it to an attached EntityEventBus.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Parameters
| Parameter | Type |
|---|---|
event | CdcEvent<T> |
Returns
Promise<void>
subscribe()
subscribe<
T>(filterOrTable,handler): () =>void
Defined in: src/realtime/CdcEmitter.ts:66
Subscribes to CDC events matching a filter object or table name. Returns an unsubscribe function.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Parameters
| Parameter | Type |
|---|---|
filterOrTable | string | CdcSubscriptionFilter |
handler | CdcHandler<T> |
Returns
() => void
on()
on<
T>(table,handler): () =>void
Defined in: src/realtime/CdcEmitter.ts:85
Subscribes to events for a specific table name.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Parameters
| Parameter | Type |
|---|---|
table | string |
handler | CdcHandler<T> |
Returns
() => void
parsePostgresPayload()
staticparsePostgresPayload(rawPayload):CdcEvent<any> |null
Defined in: src/realtime/CdcEmitter.ts:92
Helper that parses a PostgreSQL LISTEN/NOTIFY JSON payload into a typed CdcEvent.
Parameters
| Parameter | Type |
|---|---|
rawPayload | string |
Returns
CdcEvent<any> | null
Properties
eventBus?
readonlyoptionaleventBus?:EntityEventBus
Defined in: src/realtime/CdcEmitter.ts:33