Skip to main content

ensure_stream_exists

Function ensure_stream_exists 

Source
pub(crate) async fn ensure_stream_exists(
    js: &Context,
    stream_name: &str,
    subject: &str,
) -> Result<(), LJMError>
Expand description

Creates or reconciles the JetStream stream used for live LabJack samples.

The stream is configured with file storage, limit retention, old-message discard, no message or consumer limits, the byte limit from STREAM_MAX_BYTES, and the subject wildcard needed for the current source. Existing subjects are kept during namespace migrations so historical consumers remain valid until they are deliberately retired. If the stream already has these settings, nothing is written.

§Arguments

  • js - JetStream context of the local NATS server.
  • stream_name - Stream name from the configuration (nats_stream).
  • subject - Subject wildcard for this source, from subjects::live_labjack_stream_subject.

§Errors

Returns an error if STREAM_MAX_BYTES is invalid or if JetStream rejects the create or update request.