jetstream_extra/lib.rs
1// Copyright 2025 Synadia Communications Inc.
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14//! JetStream extensions for async-nats.
15//!
16//! This crate provides additional functionality for NATS JetStream that extends
17//! the capabilities of the async-nats client.
18//!
19//! # Features
20//!
21//! ## Batch Publishing
22//!
23//! The [batch_publish] module provides atomic batch publishing capabilities:
24//!
25//! ```no_run
26//! # use jetstream_extra::batch_publish::BatchPublishExt;
27//! # async fn example(client: impl BatchPublishExt) -> Result<(), Box<dyn std::error::Error>> {
28//! // Publish multiple messages as an atomic batch
29//! let mut batch = client.batch_publish().build();
30//! batch.add("events.1", "data1".into()).await?;
31//! batch.add("events.2", "data2".into()).await?;
32//! let ack = batch.commit("events.3", "final".into()).await?;
33//! # Ok(())
34//! # }
35//! ```
36//!
37//! See the [batch_publish] module for detailed documentation.
38
39pub mod batch_publish;