Packages · @purista/natsbridge
@purista/natsbridge
Package for using a [NATS](https://nats.io/) broker as event bridge. The event bridge supports brokers with and without JetStream enabled.
Signature
@purista/natsbridge Examples
import { NatsBridge } from '@purista/natsbridge'
// create and init our eventbridge
const eventBridge = new NatsBridge()
await eventBridge.start() Classes
1 entry
NatsBridge
Classes
class NatsBridge EventBridge implementation for NATS core messaging with optional JetStream.
Type Aliases
9 entries
GetCommandTopicFn
Types
type GetCommandTopicFn = (this: INatsBridge, address: EBMessageAddress) => string Function signature for building a NATS command subscription subject.
GetSubscriptionTopicFn
Types
type GetSubscriptionTopicFn = (this: INatsBridge, subscription: Subscription) => string Function signature for building a NATS subscription subject filter.
GetTopicNameFn
Types
type GetTopicNameFn = (this: INatsBridge, message: EBMessage) => string Function signature for building a NATS publish subject from a PURISTA message.
INatsBridge
Types
type INatsBridge = { connection: NatsConnection | undefined; sc: Codec<unknown> } & EventBridgeBaseClass<NatsBridgeConfig> Internal receiver shape used by exported NATS helper functions.
IncomingMessageFunction
Types
type IncomingMessageFunction = (this: INatsBridge, error: NatsError | null, msg: Msg | JsMsg) => Promise<void> NATS message handler bound to an INatsBridge instance.
NatsBridgeConfig
Types
type NatsBridgeConfig = Prettify<{ commandResponsePublishTwice: "always" | "eventOnly" | "eventAndError" | "never"; defaultConsumerFailureHandling: NatsConsumerFailureHandlingDefaults; defaultMessageExpiryInterval: number; durableSubscriptionMode: "strict" | "best-effort"; emptyTopicPartString: string; jetStreamAckWaitMs: number; ... } & ConnectionOptions> Configuration for NatsBridge.
NatsConsumerFailureHandlingDefaults
Types
type NatsConsumerFailureHandlingDefaults = void Default JetStream-backed subscription failure handling.
PausedSubscriptionState
Types
type PausedSubscriptionState = void Runtime pause metadata for a subscription consumer managed by the NATS bridge.
RegisteredSubscription
Types
type RegisteredSubscription = void NATS or JetStream subscription tracked by the bridge for cleanup.
Variables
4 entries
getCommandSubscriptionTopic
Variables
const getCommandSubscriptionTopic: GetCommandTopicFn Builds the NATS subject used by command handlers for one service address.
getSubscriptionTopic
Variables
const getSubscriptionTopic: GetSubscriptionTopicFn Builds the NATS subject filter for a PURISTA subscription definition.
getTopicName
Variables
const getTopicName: GetTopicNameFn Calculates the NATS topic name for a message which should be sent.
puristaVersion
Variables
const puristaVersion: "3.0.1" The PURISTA package version embedded in the published runtime build.
Functions
2 entries
getDefaultNatsBridgeConfig
Functions
getDefaultNatsBridgeConfig(): { commandResponsePublishTwice: "always" | "eventOnly" | "eventAndError" | "never"; defaultConsumerFailureHandling: NatsConsumerFailureHandlingDefaults; defaultMessageExpiryInterval: number; durableSubscriptionMode: "strict" | "best-effort"; emptyTopicPartString: string; jetStreamAckWaitMs: number; ... } getQueueGroupName
Functions
getQueueGroupName(prefix: string, address: EBMessageAddress): string