Crate jetstream_extra

Crate jetstream_extra 

Source
Expand description

JetStream extensions for async-nats.

This crate provides additional functionality for NATS JetStream that extends the capabilities of the async-nats client.

§Features

§Batch Publishing

The batch_publish module provides atomic batch publishing capabilities:

// Publish multiple messages as an atomic batch
let mut batch = client.batch_publish().build();
batch.add("events.1", "data1".into()).await?;
batch.add("events.2", "data2".into()).await?;
let ack = batch.commit("events.3", "final".into()).await?;

§Batch Fetching

The batch_fetch module provides efficient batch fetching of messages from streams using the DIRECT.GET API:

// Fetch 100 messages from a stream
let mut messages = context
    .get_batch("my_stream", 100)
    .send()
    .await?;

while let Some(msg) = messages.next().await {
    let msg = msg?;
    println!("Message: {:?}", msg);
}

See the batch_publish and batch_fetch modules for detailed documentation.

Modules§

batch_fetch
Batch fetch operations for JetStream streams.
batch_publish
Batch publishing support for NATS JetStream.

Structs§

StreamMessage
Re-exported type returned by Direct Get operation. A message received directly from the stream, without leveraging a consumer.
Subject
A Subject is an immutable string type that guarantees valid UTF-8 contents.