stormchaser-engine 1.3.2

A robust, distributed workflow engine for event-driven and human-triggered workflows.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use anyhow::Result;
use async_nats::jetstream::{self, stream::Config};

/// Initializes the NATS JetStream context and creates required streams if they do not exist.
pub async fn init_jetstream(nats_client: &async_nats::Client) -> Result<jetstream::Context> {
    let js = jetstream::new(nats_client.clone());

    // Ensure the stormchaser stream exists
    js.get_or_create_stream(Config {
        name: "stormchaser".to_string(),
        subjects: vec!["stormchaser.v1.>".to_string()],
        ..Default::default()
    })
    .await?;

    Ok(js)
}