@s2-dev/streamstore - v0.22.0
    Preparing search index...

    Class Producer

    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.

    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();

    Implements

    • AsyncDisposable
    Index

    Constructors

    Properties

    appendSession: AppendSession
    batchTransform: BatchTransform
    pump: Promise<void>
    readable: ReadableStream<IndexedAppendAck>
    transformReader: ReadableStreamDefaultReader<AppendInput>
    transformWriter: WritableStreamDefaultWriter<AppendRecord>
    writable: WritableStream<AppendRecord>

    Methods

    • 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.

      Returns Promise<void>