aboutsummaryrefslogtreecommitdiffstats
path: root/crates/configuration/src/server/reload_stream.rs
blob: d2ee4abf9509d0ebf43f38ebc28ef4fd3e736dee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use async_nats::jetstream::Context;
use tracing::{debug, info};

use crate::cnfg::JetstreamConfig;

pub async fn create_stream(jetstream: &Context, config: &JetstreamConfig) -> anyhow::Result<()> {
    debug!(name = ?config.stream, "initialising stream");

    jetstream
        .get_or_create_stream(async_nats::jetstream::stream::Config {
            name: config.stream.to_string(),
            max_messages: config.max_messages,
            subjects: vec![config.subject.to_string()],
            ..Default::default()
        })
        .await?;

    info!(name = ?config.stream, subject = ?config.subject, "stream is ready");

    Ok(())
}