UNPKG

@eang/core

Version:

eang - model driven enterprise event processing

53 lines (52 loc) 2.12 kB
import { Consumer, JetStreamClient, JetStreamManager, PubAck, ConsumerConfig, ConsumerInfo } from '@nats-io/jetstream'; import { Connectable, Subject } from 'rxjs'; import { ConnectionOptions, NatsConnection } from '@nats-io/nats-core'; import { IEangEvent } from './functions.js'; import { EntityEvent } from './entity.js'; import { IPublishingOptions } from './eang.js'; export interface ConsumerStream { consumer: Consumer; consumerInfo: ConsumerInfo; consumerName: string; eventSubj: Subject<IEangEvent>; event$: Connectable<IEangEvent>; startToConsume: () => Promise<void>; } interface ConsumerStreams { [key: string]: ConsumerStream; } export declare class NatsStreamService { readonly consumerData: ConsumerStreams; nc: NatsConnection; js: JetStreamClient; jsm: JetStreamManager; constructor(); initialize(opts: ConnectionOptions): Promise<{ nc: NatsConnection; js: JetStreamClient; jsm: JetStreamManager; }>; ensureStream(streamName: string, subjects: string[]): Promise<{ created: boolean; streamInfo: import("@nats-io/jetstream").StreamInfo; }>; deleteStream(streamName: string): Promise<boolean>; ensureConsumer(streamName: string, consumerName: string | undefined, filter_subjects?: string[], opts?: Partial<ConsumerConfig>): Promise<{ consumer: Consumer; consumerInfo: ConsumerInfo; }>; ensureConsumerStream(consumerName: string | undefined, subscription: string[], opts?: Partial<ConsumerConfig>): Promise<ConsumerStream>; deleteConsumerStream(consumerName: string): Promise<boolean>; startToConsume(consumerName: string): Promise<void>; publish(events: EntityEvent[], options: IPublishingOptions): Promise<PubAck[]>; } /** * Escapes only NATS-specific special characters: . * > and space * Uses a single pass for maximum efficiency */ export declare function escapeSubjectToken(token: string | undefined): string; /** * Unescapes a subject token by URL-decoding it */ export declare function unescapeSubjectToken(token: string): string; export {};