Skip to content

PURISTA API


PURISTA API / @purista/core / EventBridge

Interface: EventBridge

Defined in: core/EventBridge/types/EventBridge.ts:26

Event bridge interface The event bridge must implement this interface.

Properties

capabilities

readonly capabilities: EventBridgeCapabilities

Defined in: core/EventBridge/types/EventBridge.ts:28


defaultCommandTimeout

readonly defaultCommandTimeout: number

Defined in: core/EventBridge/types/EventBridge.ts:34

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


instanceId

readonly instanceId: string

Defined in: core/EventBridge/types/EventBridge.ts:30


name

readonly name: string

Defined in: core/EventBridge/types/EventBridge.ts:27

Methods

destroy()

destroy(): Promise<void>

Defined in: core/EventBridge/types/EventBridge.ts:129

Shut down event bridge as gracefully as possible

Returns

Promise<void>


emitMessage()

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

Defined in: core/EventBridge/types/EventBridge.ts:45

Emit a message to the eventbridge without awaiting a result

Parameters

message

Omit<EBMessage, "id" | "timestamp" | "correlationId">

the message

Returns

Promise<Readonly<EBMessage>>


getInFlightExecutionCount()

getInFlightExecutionCount(): number

Defined in: core/EventBridge/types/EventBridge.ts:134

Number of currently running handlers across all work kinds.

Returns

number


getInFlightExecutionCounts()

getInFlightExecutionCounts(): InFlightExecutionCounts

Defined in: core/EventBridge/types/EventBridge.ts:139

Number of currently running handlers grouped by work kind.

Returns

InFlightExecutionCounts


getPausedSubscriptionConsumers()

getPausedSubscriptionConsumers(): PausedSubscriptionConsumersByRegistrationKey

Defined in: core/EventBridge/types/EventBridge.ts:144

Returns paused subscription consumer states keyed by adapter registration key.

Returns

PausedSubscriptionConsumersByRegistrationKey


invoke()

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

Defined in: core/EventBridge/types/EventBridge.ts:52

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

Type Parameters

T

T

Parameters

input

Omit<Command, "id" | "messageType" | "timestamp" | "correlationId">

a partial command message

ttl?

number

the time to live (timeout) of the invocation

Returns

Promise<T>


isHealthy()

isHealthy(): Promise<boolean>

Defined in: core/EventBridge/types/EventBridge.ts:124

Indicates if the eventbridge is running and works correctly

Returns

Promise<boolean>


isReady()

isReady(): Promise<boolean>

Defined in: core/EventBridge/types/EventBridge.ts:119

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

Returns

Promise<boolean>


openStream()

openStream<Chunk, Final>(input, ttl?): Promise<StreamHandle<Chunk, Final>>

Defined in: core/EventBridge/types/EventBridge.ts:58

Open a stream invocation. The returned handle can be consumed via async iteration and can be cancelled by caller.

Type Parameters

Chunk

Chunk = unknown

Final

Final = unknown

Parameters

input

Omit<StreamOpenRequest, "id" | "messageType" | "timestamp" | "correlationId">

ttl?

number

Returns

Promise<StreamHandle<Chunk, Final>>


registerCommand()

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

Defined in: core/EventBridge/types/EventBridge.ts:68

Parameters

address

EBMessageAddress

the address of the service command (service name, version and command name)

cb

(message) => 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

metadata

CommandDefinitionMetadataBase

eventBridgeConfig

DefinitionEventBridgeConfig

Returns

Promise<string>


registerStream()

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

Defined in: core/EventBridge/types/EventBridge.ts:82

Register a service stream.

Parameters

address

EBMessageAddress

cb

(message) => Promise<void>

metadata

StreamDefinitionMetadataBase

eventBridgeConfig

DefinitionEventBridgeConfig

Returns

Promise<string>


registerSubscription()

registerSubscription(subscription, cb): Promise<string>

Defined in: core/EventBridge/types/EventBridge.ts:105

Register a new subscription

Parameters

subscription

Subscription

the subscription definition

cb

(message) => Promise<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"> | undefined>

the function to be called if a matching message arrives

Returns

Promise<string>


resumeSubscriptionConsumer()

resumeSubscriptionConsumer(registrationKey): Promise<void>

Defined in: core/EventBridge/types/EventBridge.ts:149

Resumes a paused subscription consumer by registration key.

Parameters

registrationKey

string

Returns

Promise<void>


start()

start(): Promise<void>

Defined in: core/EventBridge/types/EventBridge.ts:39

Start the eventbridge and connect to the underlaying message broker

Returns

Promise<void>


unregisterCommand()

unregisterCommand(address): Promise<void>

Defined in: core/EventBridge/types/EventBridge.ts:93

Unregister a service command

Parameters

address

EBMessageAddress

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

Returns

Promise<void>


unregisterStream()

unregisterStream(address): Promise<void>

Defined in: core/EventBridge/types/EventBridge.ts:98

Unregister a service stream

Parameters

address

EBMessageAddress

Returns

Promise<void>


unregisterSubscription()

unregisterSubscription(address): Promise<void>

Defined in: core/EventBridge/types/EventBridge.ts:114

Parameters

address

EBMessageAddress

Returns

Promise<void>