Classes · @purista/dapr-sdk
DaprEventBridge
Event bridge that connects PURISTA services to the local Dapr sidecar.
Signature
class DaprEventBridgeExamples
import { DaprConfigStore, DaprEventBridge, DaprSecretStore, DaprStateStore } from '@purista/dapr-sdk'
const eventBridge = new DaprEventBridge({
serve,
})
// start the services first ...
await eventBridge.start()[Hono website](https://hono.dev)
Constructors
1 entry
constructor
Constructor
new constructor(config: { apiPrefix: string; clientConfig: DaprClientConfig; commandPayloadAsCloudEvent: boolean; defaultCommandTimeout: number; enableHttpCompression: boolean; enableRestApiExpose: boolean; ... })Creates a Dapr-backed event bridge.
Properties
14 entries
app
Property
app: HonoHono application that hosts health, command, subscription and REST projection routes.
capabilities
Property
capabilities: EventBridgeCapabilitiesRuntime capability matrix used for strict startup validation.
client
Property
client: HttpEventBridgeClientHTTP client adapter used for outgoing command invocations, event publication and health checks.
config
Property
config: Complete<EventBridgeConfig<ConfigType>>defaultCommandTimeout
Property
defaultCommandTimeout: numberThe default time until when a command invocation automatically returns a time out error
inFlightExecutions
Property
inFlightExecutions: InFlightExecutionTrackerinstanceId
Property
instanceId: stringStable runtime instance id used to distinguish bridge processes.
isShuttingDown
Property
isShuttingDown: booleanIndicates that shutdown has started and new HTTP requests should be rejected.
isStarted
Property
isStarted: booleanIndicates that the bridge has registered routes and started its HTTP server.
logger
Property
logger: LoggermetricsRecorder
Property
metricsRecorder: PuristaMetricsRecordername
Property
name: stringHuman-readable bridge name used in logs, traces, and metrics.
server
Property
server: Server<typeof IncomingMessage, typeof ServerResponse> | Http2Server<typeof IncomingMessage, typeof ServerResponse, typeof Http2ServerRequest, typeof Http2ServerResponse> | Http2SecureServer<typeof IncomingMessage, typeof ServerResponse, typeof Http2ServerRequest, typeof Http2ServerResponse> | undefinedRuntime server returned by the configured Hono `serve` adapter.
traceProvider
Property
traceProvider: NodeTracerProviderMethods
22 entries
destroy
Method
destroy(): Promise<void>Shut down event bridge as gracefully as possible
emitMessage
Method
emitMessage<T>(message: Omit<EBMessage, "id" | "timestamp" | "correlationId">): Promise<Readonly<EBMessage>>Publishes an event message through the configured HTTP client.
getInFlightExecutionCount
Method
getInFlightExecutionCount(): numberNumber of currently running handlers across all work kinds.
getInFlightExecutionCounts
Method
getInFlightExecutionCounts(): InFlightExecutionCountsNumber of currently running handlers grouped by work kind.
getPausedSubscriptionConsumers
Method
getPausedSubscriptionConsumers(): PausedSubscriptionConsumersByRegistrationKeyReturns paused subscription consumer states keyed by adapter registration key.
getTracer
Method
getTracer(): TracerReturns open telemetry tracer of this service
invoke
Method
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
isHealthy(): Promise<boolean>Reports whether the bridge is started and its sidecar/platform client is reachable.
isReady
Method
isReady(): Promise<boolean>Reports whether the bridge can accept new HTTP requests.
openStream
Method
openStream<Chunk, Final>(_input: Omit<StreamOpenRequest, "id" | "messageType" | "timestamp" | "correlationId">, _ttl?: number): Promise<StreamHandle<Chunk, Final>>Open a stream invocation.
registerCommand
Method
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(_address: EBMessageAddress, _cb: (message: StreamMessage) => Promise<void>, _metadata: StreamDefinitionMetadataBase, _eventBridgeConfig: DefinitionEventBridgeConfig): Promise<string>Register a service stream handler for a service target.
registerSubscription
Method
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 PURISTA subscription and exposes it to Dapr Pub/Sub discovery.
resumeSubscriptionConsumer
Method
resumeSubscriptionConsumer(_registrationKey: string): Promise<void>Resumes a paused subscription consumer by registration key.
runInFlight
Method
runInFlight<T>(fn: () => Promise<T>, kind?: "command" | "subscription" | "stream" | "generic"): Promise<T>start
Method
start(): Promise<void>Registers Dapr discovery routes and starts the HTTP event bridge.
startActiveSpan
Method
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
unregisterCommand(address: EBMessageAddress): Promise<void>Placeholder for transport-specific command unregistration.
unregisterStream
Method
unregisterStream(_address: EBMessageAddress): Promise<void>Unregister a service stream
unregisterSubscription
Method
unregisterSubscription(address: EBMessageAddress): Promise<void>Placeholder for transport-specific subscription unregistration.
waitForInFlightDrain
Method
waitForInFlightDrain(timeoutMs?: number): Promise<boolean>wrapInSpan
Method
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!