edgeport - v1.0.3
    Preparing search index...

    Interface JetStreamManager

    A JetStream context bound to one NatsConnection.

    Obtain it from jetstream. It exposes the minimal surface needed for durable, no-loss / no-dup pipelines: ensure a stream, publish with a PubAck, and bind a durable pull consumer.

    1.0.0

    interface JetStreamManager {
        ensureStream(
            name: string,
            opts: EnsureStreamOptions,
        ): Promise<StreamInfo>;
        publish(
            subject: string,
            data?: string | Uint8Array<ArrayBufferLike>,
            opts?: JsPublishOptions,
        ): Promise<PubAck>;
        pullSubscribe(
            stream: string,
            durable: string,
            opts?: PullSubscribeOptions,
        ): Promise<PullConsumer>;
    }
    Index
    • Creates a stream if it does not exist, or treats an existing same-named stream as success.

      Idempotent: a "stream name already in use" error is swallowed and the existing stream's info is fetched and returned instead.

      Parameters

      • name: string

        The stream name (no ., *, >, or whitespace).

      • opts: EnsureStreamOptions

        The subjects to bind and optional storage backend.

      Returns Promise<StreamInfo>

      Basic info about the (now-existing) stream.

      If the server rejects the create for any reason other than already-exists.

      If the API request times out.

    • Publishes a message to a stream-bound subject and waits for the PubAck.

      Parameters

      • subject: string

        A subject captured by some stream.

      • Optionaldata: string | Uint8Array<ArrayBufferLike>

        The payload (string is UTF-8 encoded).

      • Optionalopts: JsPublishOptions

        Optional ack timeout and dedup id.

      Returns Promise<PubAck>

      The PubAck with the stream name and assigned sequence.

      If JetStream returns an error (e.g. no stream binds the subject).

      If no PubAck arrives before the deadline.

    • Creates or binds a durable pull consumer with an explicit ack policy.

      Idempotent on the durable name: re-binding an existing durable returns a consumer over the same server-side cursor (the basis of the reconnect / no-loss-no-dup behaviour).

      Parameters

      • stream: string

        The stream to consume from.

      • durable: string

        The durable name (stable across connections; no ., *, >, whitespace).

      • Optionalopts: PullSubscribeOptions

        Optional ack policy, ack-wait, and deliver policy.

      Returns Promise<PullConsumer>

      A PullConsumer bound to (stream, durable).

      If the server rejects the create for any reason other than already-exists.

      If the API request times out.