انتقل إلى المحتوى الرئيسي

Class: EventPublisher

Defined in: packages/messaging/src/events.ts:79

Publishes events into JetStream, over the envelope. Strict on send. The constructor is where "a producer without a registered schema fails to start" is enforced: an unregistered key, or a module the permission table does not list as a publisher of it, throws before the first message.

Constructors​

Constructor​

new EventPublisher(options): EventPublisher

Defined in: packages/messaging/src/events.ts:91

Parameters​

options​

EventPublisherOptions

Returns​

EventPublisher

Throws​

A key has no registered schema.

Throws​

The module is not a listed publisher of a key.

Methods​

publish()​

publish<K>(key, event): Promise<{ duplicate: boolean; seq: number; }>

Defined in: packages/messaging/src/events.ts:126

Publishes one event and waits for JetStream to store it.

Type Parameters​

K​

K extends EventKey

Parameters​

key​

K

A key declared at construction.

event​

EventPublication<K>

The tenant, body, actor and ids.

Returns​

Promise<{ duplicate: boolean; seq: number; }>

duplicate is true when the stream had already stored this msgId inside its window, which is success, not failure.

Throws​

The key was not declared at construction.

Throws​

The body or envelope is invalid (a defect in the producer, and it must not reach the stream), or the broker did not acknowledge in time.