UNPKG

@cloudamqp/amqp-client

Version:

AMQP 0-9-1 client, both for browsers (WebSocket) and node (TCP Socket)

92 lines 3.55 kB
import { AMQPChannel } from "./amqp-channel.js"; import { AMQPError } from "./amqp-error.js"; import { AMQPView } from "./amqp-view.js"; import type { Logger } from "./types.js"; export declare const VERSION = "4.0.0"; export declare const MIN_FRAME_SIZE = 8192; /** * Base class for AMQPClients. * Implements everything except how to connect, send data and close the socket */ export declare abstract class AMQPBaseClient { /** Virtual host to connect to. */ vhost: string; /** Username for authentication. */ username: string; /** Password for authentication. */ password: string; /** Connection name, visible in the RabbitMQ management UI. */ name?: string; /** Platform identifier sent in client properties. */ platform?: string; /** Open channels, indexed by channel id. */ channels: AMQPChannel[]; protected connectPromise?: [(conn: AMQPBaseClient) => void, (err: Error) => void]; protected closePromise?: [(value?: void) => void, (err: Error) => void]; protected onUpdateSecretOk?: (value?: void) => void; /** Whether the connection is closed. */ closed: boolean; /** Set when the server has blocked publishing (connection.blocked reason). */ blocked?: string; /** Maximum number of channels negotiated with the server. */ channelMax: number; /** Maximum frame size in bytes negotiated with the server. */ frameMax: number; /** Heartbeat interval in seconds. */ heartbeat: number; /** Callback for connection-level errors. */ onerror: (error: AMQPError) => void; /** Logger instance, or undefined to disable logging. */ logger: Logger | undefined; /** * Callback when connection is lost * @param error - The error that caused the disconnection, if any */ ondisconnect?: (error?: Error) => void; /** * Callback when the server blocks publishing on this connection * (typically due to a resource alarm — memory or disk). * @param reason - The broker-supplied reason string */ onblocked?: (reason: string) => void; /** * Callback when the server lifts a previous block on this connection. */ onunblocked?: () => void; /** * @param name - name of the connection, set in client properties * @param platform - used in client properties * @param logger - optional logger instance, defaults to undefined (no logging) */ constructor(vhost: string, username: string, password: string, name?: string, platform?: string, frameMax?: number, heartbeat?: number, channelMax?: number, logger?: Logger | null); /** * Open a channel * @param [id] - An existing or non existing specific channel */ channel(id?: number): Promise<AMQPChannel>; /** * Gracefully close the AMQP connection. * @param [reason] might be logged by the server */ close(reason?: string, code?: number): Promise<void>; updateSecret(newSecret: string, reason: string): Promise<unknown>; /** * Try establish a connection */ abstract connect(): Promise<AMQPBaseClient>; /** * @ignore * @param bytes to send * @return fulfilled when the data is enqueued */ abstract send(bytes: Uint8Array): Promise<void>; protected abstract closeSocket(): void; private rejectClosed; private rejectConnect; /** * Parse and act on frames in an AMQPView * @ignore */ protected parseFrames(view: AMQPView): void; } //# sourceMappingURL=amqp-base-client.d.ts.map