import type { NatsConnection } from '@nats-io/nats-core'; import type { FrameParts } from './codec.js'; export declare const PUBLISH_FRAME_MIN_SIZE: number; /** * Publish a CUIB frame as one buffer holding the PUB line, the frame and the * CRLF. nats-core queues a publish as three buffers and packs them into a * fresh copy before the socket write; a single queued buffer goes out as it * is. The buffer is allocated here, so no caller buffer is referenced after * return, the same as with the stock path. * * Node only. Returns false when the connection lacks the nats-core internals * this relies on, then the caller publishes the stock way. */ export declare function publishFrame(nc: NatsConnection, subject: string, reply: string | undefined, parts: FrameParts): boolean; /** * Publish a CUIB frame without copying its segments. The PUB line, the frame * header and the envelope go out as one new buffer, every segment as the * caller's own buffer, all in one corked socket write. The socket holds the * segments until the kernel has taken them, so the caller must not change or * release them before that; a reply to the request proves it. * * Node only and only while connected: a frame queued for a reconnect would * hold the segments for an unknown time. Returns false otherwise or when the * connection lacks the nats-core internals this relies on, then the caller * publishes a copy. */ export declare function publishFrameZeroCopy(nc: NatsConnection, subject: string, reply: string | undefined, parts: FrameParts): boolean; /** * Hand what nats-core has queued for the socket to the transport now instead * of in its microtask. Node only; a no-op when the connection lacks the * nats-core internals, then the queue is written as usual. */ export declare function flushOutbound(nc: NatsConnection): void; /** * Presize the payload buffer of a message that is split across socket reads. * * Stock nats-core copies the first part into a buffer of that size and grows * it by doubling, so a large message is copied several times and held in a * buffer up to twice its size. The patch moves the first part into a buffer * of the announced message size, later parts are written in place. Bytes and * events stay the same. * * Applied once per process and only under Node; the browser runs the forked * parser. Returns whether the patch is active: false when the installed * nats-core does not have the expected shape, then the stock parser runs. */ export declare function presizeSplitPayloads(): boolean; /** * Lighter small publishes on Node TCP connections. nats-core encodes every * protocol line with a TextEncoder, packs the queued buffers into a fresh * copy and wraps each socket write in a promise with a catch. The patch * queues a line as a string, writes all that is queued into one Buffer at * the flush and hands it to the socket without a promise. Bytes, order, the * inline flush at the pending limit and the buffering while reconnecting * stay the same. * * Applied once per process and only under Node, to connections on the * NodeTransport of @nats-io/transport-node; any other transport keeps the * stock path. Returns whether the patch is active: false when the installed * nats-core does not have the expected shape, then the stock path runs. */ export declare function packSmallPublishes(): boolean; /** * Read Node TCP connections through one buffer per process. Node allocates * a fresh 64 KiB buffer for every socket read; with the patch the socket * reads into a shared buffer and each read is copied out into a buffer of * its exact size before nats-core sees it, so no view of the shared buffer * escapes. Received bytes and their order stay the same. * * Applied once per process and only under Node, to the NodeTransport of * @nats-io/transport-node. A connection with TLS options, or to a server * that asked for TLS once, dials the stock way: TLS cannot start on such a * socket. Returns whether the patch is active: false when the installed * transport does not have the expected shape, then the stock path runs. */ export declare function shareReadBuffer(): boolean; /** * Whether a socket reads through the shared buffer of shareReadBuffer(). * * Internal: the patch and its tests use it. */ export declare function readsShared(socket: unknown): boolean;