Classes · @purista/base-http-bridge

HttpEventBridge

Stores the app value exposed by HttpEventBridge. Start the bridge before registering services and stop it during graceful shutdown. Expose only schemas and metadata that are safe for clients to inspect. Treat this property as runtime state unless the concrete API documents a stronger guarantee.

Signature

HttpEventBridge.ts typescript
class HttpEventBridge<CustomConfig>

Constructors

1 entry

constructor

Constructor

Source
constructor.ts typescript
new constructor<CustomConfig>(config: mapped, client: HttpEventBridgeClient)

Creates an HTTP event bridge around a sidecar/platform client.

Properties

14 entries

app

Property

Source
app.ts typescript
app: Hono

Hono application that hosts health, command, subscription and REST projection routes.

capabilities

Property

capabilities.ts typescript
capabilities: EventBridgeCapabilities

Runtime capability matrix used for strict startup validation.

client

Property

Source
client.ts typescript
client: HttpEventBridgeClient

HTTP client adapter used for outgoing command invocations, event publication and health checks.

config

Property

config.ts typescript
config: Complete<EventBridgeConfig<ConfigType>>

defaultCommandTimeout

Property

defaultCommandTimeout.ts typescript
defaultCommandTimeout: number

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

inFlightExecutions

Property

inFlightExecutions.ts typescript
inFlightExecutions: InFlightExecutionTracker

instanceId

Property

instanceId.ts typescript
instanceId: string

Stable runtime instance id used to distinguish bridge processes.

isShuttingDown

Property

Source
isShuttingDown.ts typescript
isShuttingDown: boolean

Indicates that shutdown has started and new HTTP requests should be rejected.

isStarted

Property

Source
isStarted.ts typescript
isStarted: boolean

Indicates that the bridge has registered routes and started its HTTP server.

logger

Property

logger.ts typescript
logger: Logger

metricsRecorder

Property

metricsRecorder.ts typescript
metricsRecorder: PuristaMetricsRecorder

name

Property

name.ts typescript
name: string

Human-readable bridge name used in logs, traces, and metrics.

server

Property

Source
server.ts typescript
server: Server<typeof IncomingMessage, typeof ServerResponse> | Http2Server<typeof IncomingMessage, typeof ServerResponse, typeof Http2ServerRequest, typeof Http2ServerResponse> | Http2SecureServer<typeof IncomingMessage, typeof ServerResponse, typeof Http2ServerRequest, typeof Http2ServerResponse> | undefined

Runtime server returned by the configured Hono `serve` adapter.

traceProvider

Property

traceProvider.ts typescript
traceProvider: NodeTracerProvider

Methods

22 entries

destroy

Method

Source
destroy.ts typescript
destroy(): Promise<void>

Shut down event bridge as gracefully as possible

emitMessage

Method

Source
emitMessage.ts typescript
emitMessage<T>(message: Omit<EBMessage, "id" | "timestamp" | "correlationId">): Promise<Readonly<EBMessage>>

Publishes an event message through the configured HTTP client.

getInFlightExecutionCount

Method

getInFlightExecutionCount.ts typescript
getInFlightExecutionCount(): number

Number of currently running handlers across all work kinds.

getInFlightExecutionCounts

Method

getInFlightExecutionCounts.ts typescript
getInFlightExecutionCounts(): InFlightExecutionCounts

Number of currently running handlers grouped by work kind.

getPausedSubscriptionConsumers

Method

getPausedSubscriptionConsumers.ts typescript
getPausedSubscriptionConsumers(): PausedSubscriptionConsumersByRegistrationKey

Returns paused subscription consumer states keyed by adapter registration key.

getTracer

Method

getTracer.ts typescript
getTracer(): Tracer

Returns open telemetry tracer of this service

invoke

Method

Source
invoke.ts typescript
invoke<T>(input: Omit<Command, "id" | "messageType" | "timestamp" | "correlationId">, ttl?: number): Promise<T>

Invokes a PURISTA command over HTTP and returns the command payload.

isHealthy

Method

Source
isHealthy.ts typescript
isHealthy(): Promise<boolean>

Reports whether the bridge is started and its sidecar/platform client is reachable.

isReady

Method

Source
isReady.ts typescript
isReady(): Promise<boolean>

Reports whether the bridge can accept new HTTP requests.

openStream

Method

openStream.ts typescript
openStream<Chunk, Final>(_input: Omit<StreamOpenRequest, "id" | "messageType" | "timestamp" | "correlationId">, _ttl?: number): Promise<StreamHandle<Chunk, Final>>

Open a stream invocation.

registerCommand

Method

Source
registerCommand.ts typescript
registerCommand(address: EBMessageAddress, cb: (message: { contentEncoding: string; contentType: string; correlationId: string; eventName: string; id: string; messageType: Command; ... }) => Promise<Readonly<Omit<unknown, unknown>> | Readonly<Omit<unknown, unknown>>>, metadata: { expose: { contentEncodingRequest: string; contentEncodingResponse: string; contentTypeRequest: string; contentTypeResponse: string; deprecated: boolean; inputPayload: SchemaObject; ... } & { http: { method: unknown | unknown | unknown | unknown | unknown; mode: unknown | unknown; openApi: { additionalStatusCodes: unknown; description: unknown; isSecure: unknown; operationId: unknown; query: unknown; summary: unknown; ... }; path: string; stream: { documentationUrl: unknown; mode: unknown; protocol: unknown } } } }, eventBridgeConfig: DefinitionEventBridgeConfig): Promise<string>

Registers the internal command endpoint, plus an optional REST projection.

registerStream

Method

registerStream.ts typescript
registerStream(_address: EBMessageAddress, _cb: (message: StreamMessage) => Promise<void>, _metadata: StreamDefinitionMetadataBase, _eventBridgeConfig: DefinitionEventBridgeConfig): Promise<string>

Register a service stream handler for a service target.

registerSubscription

Method

Source
registerSubscription.ts typescript
registerSubscription(subscription: Subscription, cb: (message: EBMessage) => Promise<Omit<{ contentEncoding: unknown; contentType: unknown; correlationId: unknown; eventName: unknown; id: unknown; messageType: unknown; ... }, unknown | unknown> | undefined>): Promise<string>

Registers a subscription endpoint before the HTTP server starts.

resumeSubscriptionConsumer

Method

resumeSubscriptionConsumer.ts typescript
resumeSubscriptionConsumer(_registrationKey: string): Promise<void>

Resumes a paused subscription consumer by registration key.

runInFlight

Method

runInFlight.ts typescript
runInFlight<T>(fn: () => Promise<T>, kind?: "command" | "subscription" | "stream" | "generic"): Promise<T>

start

Method

Source
start.ts typescript
start(): Promise<void>

Starts the Hono server and registers common middleware and the `/healthz` route.

startActiveSpan

Method

startActiveSpan.ts typescript
startActiveSpan<F>(name: string, opts: SpanOptions, context: Context | undefined, fn: (span: Span) => Promise<F>): Promise<F>

Start a child span for opentelemetry tracking

unregisterCommand

Method

Source
unregisterCommand.ts typescript
unregisterCommand(address: EBMessageAddress): Promise<void>

Placeholder for transport-specific command unregistration.

unregisterStream

Method

unregisterStream.ts typescript
unregisterStream(_address: EBMessageAddress): Promise<void>

Unregister a service stream

unregisterSubscription

Method

Source
unregisterSubscription.ts typescript
unregisterSubscription(address: EBMessageAddress): Promise<void>

Placeholder for transport-specific subscription unregistration.

waitForInFlightDrain

Method

waitForInFlightDrain.ts typescript
waitForInFlightDrain(timeoutMs?: number): Promise<boolean>

wrapInSpan

Method

wrapInSpan.ts typescript
wrapInSpan<F>(name: string, opts: SpanOptions, fn: (span: Span) => Promise<F>, context?: Context): Promise<F>

Start span for opentelemetry tracking on same level. The created span will not become the "active" span within opentelemetry!