@mastra/core
Version:
36 lines • 1.49 kB
TypeScript
import type { Event, EventCallback, SubscribeBatchOptions } from '../types.js';
import type { BatchPolicyDeps } from './batch-policy.js';
/**
* In-process queue used by `EventEmitterPubSub` to turn its
* one-event-per-emit stream into batched callback invocations.
* Owns a `BatchPolicy` that decides when to flush (size, time,
* quiet-period) and holds (event, ack, nack) triples in publish
* order until that decision fires.
*
* Extracted from `EventEmitterPubSub` only so the batching state
* machine can be tested in isolation. Not a public extension point.
* State is per-process; the queue dies with the process.
*/
export declare class AckHandleBuffer {
private readonly cb;
private readonly onError?;
private readonly policy;
private queue;
private flushing;
private reflush;
private disposed;
constructor(cb: EventCallback, opts: SubscribeBatchOptions, deps?: BatchPolicyDeps, onError?: ((err: unknown, ctx: {
phase: "cb" | "ack-dropped";
}) => void) | undefined);
/**
* Called by the adapter for each event arriving from the underlying transport.
*/
push(event: Event, ack?: () => Promise<void>, nack?: () => Promise<void>): Promise<void>;
/**
* Drain the current queue regardless of policy state. Safe to call from
* adapter `flush()` or external code that wants to force delivery.
*/
flush(): Promise<void>;
dispose(): void;
}
//# sourceMappingURL=ack-handle-buffer.d.ts.map