@tawk.to/nestjs-google-pubsub-microservice
Version:
NestJS Google Cloud Pub/Sub Microservice Transport
41 lines (40 loc) • 2.24 kB
TypeScript
import { ClientConfig, CreateSubscriptionOptions, Message, PubSub, Subscription } from '@google-cloud/pubsub';
import { PublishOptions } from '@google-cloud/pubsub/build/src/publisher';
import { SubscriberOptions } from '@google-cloud/pubsub/build/src/subscriber';
import { CustomTransportStrategy, Server } from '@nestjs/microservices';
import { Logger } from '@nestjs/common';
import { GCPubSubServerOptions } from './gc-pubsub.interface';
import { IGCPubSubParser } from './gc-pubsub.parser';
import { GCPubSubEvents } from './gc-pubsub.events';
export declare class GCPubSubServer extends Server<GCPubSubEvents> implements CustomTransportStrategy {
protected readonly options: GCPubSubServerOptions;
protected logger: Logger;
protected readonly clientConfig: ClientConfig;
protected readonly topicName: string;
protected readonly publisherConfig: PublishOptions;
protected readonly subscriptionName: string;
protected readonly subscriberConfig: SubscriberOptions;
protected readonly noAck: boolean;
protected readonly replyTopics: Set<string>;
protected readonly init: boolean;
protected readonly checkExistence: boolean;
protected readonly createSubscriptionOptions: CreateSubscriptionOptions;
protected readonly ackAfterResponse: boolean;
protected readonly parser: IGCPubSubParser;
protected pendingEventListeners: Array<{
event: keyof GCPubSubEvents;
callback: GCPubSubEvents[keyof GCPubSubEvents];
}>;
client: PubSub | null;
subscription: Subscription | null;
constructor(options: GCPubSubServerOptions);
listen(callback: () => void): Promise<void>;
close(): Promise<void>;
handleMessage(message: Message): Promise<any>;
sendMessage<T = any>(message: T, replyTo: string, id: string, attributes?: Record<string, string>): Promise<void>;
protected initializeSerializer(options: GCPubSubServerOptions): void;
createIfNotExists(create: () => Promise<any>): Promise<void>;
createClient(): PubSub;
on<EventKey extends keyof GCPubSubEvents = keyof GCPubSubEvents, EventCallback extends GCPubSubEvents[EventKey] = GCPubSubEvents[EventKey]>(event: EventKey, callback: EventCallback): void;
unwrap<T>(): T;
}