1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//! NATS client connection utilities.
//!
//! Convenience helpers for creating `async_nats::Client` instances with sensible
//! defaults. These are separate from `NatsTransportBuilder` — the builder accepts
//! a pre-instantiated `Arc<Client>` so callers can manage TLS/auth themselves.
//! This module provides a quick path for common configurations.
use Arc;
/// Connect to a NATS server with default options.
///
/// Returns an `Arc<async_nats::Client>` ready to pass to `NatsTransportBuilder::new()`.
///
/// # Arguments
///
/// * `url` - NATS server URL (e.g., `"nats://localhost:4222"`)
///
/// # Example
///
/// ```no_run
/// # async fn example() -> Result<(), async_nats::ConnectError> {
/// use crate::transports::nats::utils::connect;
/// let client = connect("nats://localhost:4222").await?;
/// # Ok(())
/// # }
/// ```
pub async
/// Connect to a NATS server with custom options.
///
/// Applies the given options before connecting. Use this for TLS, authentication,
/// custom timeouts, or other advanced configuration.
///
/// # Arguments
///
/// * `url` - NATS server URL (e.g., `"nats://localhost:4222"`)
/// * `options` - Pre-configured [`async_nats::ConnectOptions`]
///
/// # Example
///
/// ```no_run
/// # async fn example() -> Result<(), async_nats::ConnectError> {
/// use crate::transports::nats::utils::connect_with_options;
/// let options = async_nats::ConnectOptions::new()
/// .name("velo-instance-1");
/// let client = connect_with_options("nats://localhost:4222", options).await?;
/// # Ok(())
/// # }
/// ```
pub async