import { type BatchOutput, BatchTransform } from "./batch-transform.js"; import type { AppendSession } from "./lib/stream/types.js"; import { type AppendAck, type AppendRecord } from "./types.js"; export declare class IndexedAppendAck { readonly index: number; readonly ack: AppendAck; constructor(index: number, ack: AppendAck); batchAppendAck(): AppendAck; seqNum(): number; } export declare class RecordSubmitTicket { private readonly ackPromise; constructor(ackPromise: Promise); /** * Returns a promise that resolves with the IndexedAppendAck once the record is durable. */ ack(): Promise; } /** * Producer provides per-record append semantics on top of a batched AppendSession. * * - submit(record) returns a Promise that resolves once the record * has been accepted (written to the batch transform). Backpressure is applied * automatically via the transform stream when the AppendSession is at capacity. * - ticket.ack() returns a Promise that resolves once the record is durable. * * See the "Producer API" section of the root README for guidance on sizing batches, * wiring transforms, and handling application-level ids. * * @example * ```ts * const appendSession = await stream.appendSession(); * const producer = new Producer(new BatchTransform(), appendSession); * const writer = producer.writable.getWriter(); * await writer.write(AppendRecord.string({ body: "hello" })); * await writer.close(); * * for await (const ack of producer.readable) { * console.log("record durable at seq", ack.seqNum()); * } * * await producer.close(); * ``` */ export declare class Producer implements AsyncDisposable { readonly batchTransform: BatchTransform; readonly transformWriter: WritableStreamDefaultWriter; readonly transformReader: ReadableStreamDefaultReader; readonly pump: Promise; readonly appendSession: AppendSession; readonly readable: ReadableStream; readonly writable: WritableStream; private readonly inflightRecords; private pumpError; private readableController; private readonly debugName; private submitCounter; private closePromise; constructor(batchTransform: BatchTransform, appendSession: AppendSession, debugName?: string); /** * Main pump loop: reads batches from transform, submits to session, handles acks. */ private runPump; /** * Submit a single record for appending. * * Returns a promise that resolves to a RecordSubmitTicket once the record has been * accepted. The promise blocks if the underlying AppendSession is at capacity * (backpressure is applied via the transform stream). * * @throws S2Error if the Producer has failed */ submit(record: AppendRecord): Promise; /** * Close the Producer gracefully. * * Waits for all pending records to be flushed, submitted, and acknowledged. * If any error occurred during the Producer's lifetime, this method throws it. */ close(): Promise; private _doClose; [Symbol.asyncDispose](): Promise; } //# sourceMappingURL=producer.d.ts.map