Restate Typescript SDK
    Preparing search index...

    Interface ExactlyOnceProducerExperimental

    Sends invocations to Restate with exactly-once delivery: Restate deduplicates records on (producerId, offset), across streams and restarts. After a restart, resend from the last checkpointed offset and Restate drops the records it already committed.

    interface ExactlyOnceProducer {
        producerId: string;
        writable: WritableStream<ExactlyOnceInvocation>;
        abort(reason?: unknown): void;
        close(): Promise<void>;
        flush(): Promise<number>;
        send(record: ExactlyOnceInvocation, opts?: SendOptions): Promise<number>;
    }

    Hierarchy (View Summary)

    Index

    Properties

    producerId: string

    Stable identity of this producer.

    writable: WritableStream<ExactlyOnceInvocation>

    A WritableStream view of this producer, to pipe a source into it, e.g. with ReadableStream.pipeTo or Node's stream/promises pipeline. Writing sends the record, closing the stream closes the producer and aborting it aborts the producer.

    Methods

    • Experimental

      Sends a record.

      The returned promise resolves with the record offset once the producer has accepted the record into its buffer (or, with bufferBytes: 0, written it to the stream), waiting while the buffer is full. With waitCommitted, it resolves once Restate has durably committed the record instead.

      Always await send: calls that are not awaited keep waiting for buffer space without any bound. Records are sent in call order, so concurrent calls, e.g. with Promise.all, are safe. Note that a record rejected by validation (an oversized record, or a non-increasing exactly-once offset) rejects only its own call, while the others are still sent: with an exactly-once producer, validate records before sending them concurrently, or the commit watermark can move past the rejected offset.

      Parameters

      Returns Promise<number>