import { Server } from "@nestjs/microservices"; import type { CustomTransportStrategy } from "@nestjs/microservices"; import { type WerkenTransportOptions } from "./options.js"; export type WerkenTransportStatus = "connected" | "disconnected"; export interface WerkenTransportEvents extends Record { error: (error: unknown) => void; close: () => void; } /** * Nest custom transport for Google Cloud Pub/Sub. * * `on()` and `unwrap()` are abstract on Nest's `Server` base class — note they are NOT part of * `CustomTransportStrategy`, which requires only `listen()`/`close()`. Both must therefore be * implemented here even though nothing in the transport contract asks for them. Verified against * @nestjs/microservices 11.1.28. */ export declare class WerkenPubSubTransport extends Server implements CustomTransportStrategy { private readonly options; private client?; private subscription?; /** In-flight handlers, so shutdown can wait for them rather than cutting them off. */ private readonly inFlight; private draining; /** The in-progress drain, so every later close() awaits it rather than reporting a false finish. */ private closing?; private readonly listeners; private pipeline; private readonly idempotencyStore; private readonly telemetry; /** Built once at listen(), so patterns are not re-scanned for every message. */ private router?; /** * The prefix-resolved subscription name, once listen() has worked it out. * * Held because telemetry outside the pipeline needs it too: `CloudEventContext.subscription`, * dead-letter provenance and the pipeline's own metrics all report the resolved name, and an * in-flight series labelled with the raw one joins to none of them. */ private resolvedSubscription?; constructor(options: WerkenTransportOptions); private buildCodec; private buildPipeline; listen(callback: (...optionalParams: unknown[]) => void): void; private start; private startSubscribing; /** * Drain sequence. Nest calls this on shutdown, which needs * `app.enableShutdownHooks()` in the consumer's bootstrap — without it, scale-down kills * in-flight work and produces duplicates on every event. */ /** * Closes whatever startup managed to create before it failed, and clears the instance state so a * later close() cannot double-close it. * * Close failures are swallowed deliberately: the startup error is the one the operator needs, and * replacing it with "close failed" while unwinding would bury the actual cause. */ private closePartialStartup; /** * Drain sequence, and the answer to every later caller of it. * * Held rather than short-circuited so a second close() reports finished when the drain actually * is. Nest awaits this to decide when the process may exit, and telling it "done" while * in-flight handlers are still running is how work gets cut off at exactly the moment shutdown * was supposed to protect it. */ close(): Promise; private drain; on(event: K, callback: F): void; /** * Returns the underlying `Subscription` — not the `PubSub` client, which is what `unwrap()` * yields on most other Nest transports. The subscription is the thing this transport drives, and * the client is reachable from it; the deviation is called out because it is easy to assume * otherwise. */ unwrap(): T; /** * Readiness for Cloud Run worker pools, which have no HTTP endpoint. Prefer the `status` * observable Nest's Server already exposes when you want to react to changes. */ isHealthy(): boolean; /** The SDK's Duration class, or undefined if the peer dependency is not installed. */ private loadDuration; private createDefaultClient; private handleMessage; /** * Settles a message whose processing failed in a way nothing below could account for. * * Every step is individually guarded because the thing that failed may be the logger itself, and * a second throw here would put us back where we started — with the message abandoned. */ private abandonMessage; private processMessage; private processTraced; private emit; } //# sourceMappingURL=transport.d.ts.map