Skip to content

PURISTA API / Modules / @purista/core / EventBridge

Interface: EventBridge

@purista/core.EventBridge

Event bridge interface The event bridge must implement this interface.

Implemented by

Table of contents

Properties

Methods

Properties

defaultCommandTimeout

Readonly defaultCommandTimeout: number

The default time until when a command invocation automatically returns a time out error

Defined in

core/EventBridge/types/EventBridge.ts:26


instanceId

Readonly instanceId: string

Defined in

core/EventBridge/types/EventBridge.ts:22


name

Readonly name: string

Defined in

core/EventBridge/types/EventBridge.ts:20

Methods

destroy

destroy(): Promise<void>

Shut down event bridge as gracefully as possible

Returns

Promise<void>

Defined in

core/EventBridge/types/EventBridge.ts:99


emitMessage

emitMessage(message): Promise<Readonly<EBMessage>>

Emit a message to the eventbridge without awaiting a result

Parameters

NameTypeDescription
messageOmit<EBMessage, "correlationId" | "id" | "timestamp">the message

Returns

Promise<Readonly<EBMessage>>

Defined in

core/EventBridge/types/EventBridge.ts:37


invoke

invoke<T>(input, ttl?): Promise<T>

Call a command of a service and return the result of this command

Type parameters

Name
T

Parameters

NameTypeDescription
inputOmit<{ contentEncoding: string ; contentType: string ; correlationId: string ; eventName?: string ; id: string ; messageType: Command ; otp?: string ; payload: { parameter: unknown ; payload: unknown } ; principalId?: string ; receiver: EBMessageAddress ; sender: { instanceId: string ; serviceName: string ; serviceTarget: string ; serviceVersion: string } ; tenantId?: string ; timestamp: number ; traceId?: string }, "messageType" | "correlationId" | "id" | "timestamp">a partial command message
ttl?numberthe time to live (timeout) of the invocation

Returns

Promise<T>

Defined in

core/EventBridge/types/EventBridge.ts:46


isHealthy

isHealthy(): Promise<boolean>

Indicates if the eventbridge is running and works correctly

Returns

Promise<boolean>

Defined in

core/EventBridge/types/EventBridge.ts:94


isReady

isReady(): Promise<boolean>

Indicates if the eventbridge has been started and is connected to underlaying message broker

Returns

Promise<boolean>

Defined in

core/EventBridge/types/EventBridge.ts:89


registerCommand

registerCommand(address, cb, metadata, eventBridgeConfig): Promise<string>

Parameters

NameTypeDescription
addressEBMessageAddressthe address of the service command (service name, version and command name)
cb(message: { contentEncoding: string ; contentType: string ; correlationId: string ; eventName?: string ; id: string ; messageType: Command ; otp?: string ; payload: { parameter: unknown ; payload: unknown } ; principalId?: string ; receiver: EBMessageAddress ; sender: { instanceId: string ; serviceName: string ; serviceTarget: string ; serviceVersion: string } ; tenantId?: string ; timestamp: number ; traceId?: string }) => Promise<Readonly<Omit<{ contentEncoding: "utf-8" ; contentType: "application/json" ; correlationId: string ; eventName?: string ; id: string ; isHandledError: boolean ; messageType: CommandErrorResponse ; otp?: string ; payload: { data?: unknown ; message: string ; status: StatusCode } ; principalId?: string ; receiver: { instanceId: string ; serviceName: string ; serviceTarget: string ; serviceVersion: string } ; sender: { instanceId: string ; serviceName: string ; serviceTarget: string ; serviceVersion: string } ; tenantId?: string ; timestamp: number ; traceId?: string }, "instanceId">> | Readonly<Omit<{ contentEncoding: string ; contentType: string ; correlationId: string ; eventName?: string ; id: string ; messageType: CommandSuccessResponse ; otp?: string ; payload: unknown ; principalId?: string ; receiver: { instanceId: string ; serviceName: string ; serviceTarget: string ; serviceVersion: string } ; sender: { instanceId: string ; serviceName: string ; serviceTarget: string ; serviceVersion: string } ; tenantId?: string ; timestamp: number ; traceId?: string }, "instanceId">>>the function to be called if a matching command arrives
metadataCommandDefinitionMetadataBase-
eventBridgeConfigDefinitionEventBridgeConfig-

Returns

Promise<string>

Defined in

core/EventBridge/types/EventBridge.ts:53


registerSubscription

registerSubscription(subscription, cb): Promise<string>

Register a new subscription

Parameters

NameTypeDescription
subscriptionSubscriptionthe subscription definition
cb(message: EBMessage) => Promise<undefined | Omit<{ contentEncoding: string ; contentType: string ; correlationId?: string ; eventName: string ; id: string ; messageType: CustomMessage ; otp?: string ; payload?: unknown ; principalId?: string ; receiver?: EBMessageAddress ; sender: { instanceId: string ; serviceName: string ; serviceTarget: string ; serviceVersion: string } ; tenantId?: string ; timestamp: number ; traceId?: string }, "id" | "timestamp">>the function to be called if a matching message arrives

Returns

Promise<string>

Defined in

core/EventBridge/types/EventBridge.ts:75


start

start(): Promise<void>

Start the eventbridge and connect to the underlaying message broker

Returns

Promise<void>

Defined in

core/EventBridge/types/EventBridge.ts:31


unregisterCommand

unregisterCommand(address): Promise<void>

Unregister a service command

Parameters

NameTypeDescription
addressEBMessageAddressThe address (service name, version and command name) of the command to be de-registered

Returns

Promise<void>

Defined in

core/EventBridge/types/EventBridge.ts:68


unregisterSubscription

unregisterSubscription(address): Promise<void>

Parameters

NameType
addressEBMessageAddress

Returns

Promise<void>

Defined in

core/EventBridge/types/EventBridge.ts:84