pub struct NatsConfig {Show 16 fields
pub url: String,
pub subject: Option<String>,
pub stream: Option<String>,
pub username: Option<String>,
pub password: Option<String>,
pub tls: TlsConfig,
pub token: Option<String>,
pub request_reply: bool,
pub request_timeout_ms: Option<u64>,
pub delayed_ack: bool,
pub no_jetstream: bool,
pub subscriber_mode: bool,
pub stream_max_messages: Option<i64>,
pub deliver_policy: Option<NatsDeliverPolicy>,
pub stream_max_bytes: Option<i64>,
pub prefetch_count: Option<usize>,
}Expand description
General NATS connection configuration.
Fields§
§url: StringComma-separated list of NATS server URLs (e.g., “nats://localhost:4222,nats://localhost:4223”).
subject: Option<String>The NATS subject to publish to or subscribe to.
stream: Option<String>(Consumer only). The JetStream stream name. Required for Consumers.
username: Option<String>Optional username for authentication.
password: Option<String>Optional password for authentication.
tls: TlsConfigTLS configuration.
token: Option<String>Optional token for authentication.
request_reply: bool(Publisher only) If true, the publisher uses the request-reply pattern.
It sends a request and waits for a response (using core_client.request_with_headers()).
Defaults to false.
request_timeout_ms: Option<u64>(Publisher only) Timeout for request-reply operations in milliseconds. Defaults to 30000ms.
delayed_ack: bool(Publisher only) If true, do not wait for an acknowledgement when sending to broker. Defaults to false.
no_jetstream: boolIf no_jetstream: true, use Core NATS (fire-and-forget) instead of JetStream. Defaults to false.
subscriber_mode: bool(Consumer only) If true, use ephemeral Subscriber mode. Defaults to false (durable consumer).
stream_max_messages: Option<i64>(Publisher only) Maximum number of messages in the stream (if created by the bridge). Defaults to 1,000,000.
deliver_policy: Option<NatsDeliverPolicy>(Consumer only) The delivery policy for the consumer. Defaults to “all”.
stream_max_bytes: Option<i64>(Publisher only) Maximum total bytes in the stream (if created by the bridge). Defaults to 1GB.
prefetch_count: Option<usize>(Consumer only) Number of messages to prefetch from the consumer. Defaults to 10000.
Implementations§
Source§impl NatsConfig
impl NatsConfig
Sourcepub fn new(url: impl Into<String>) -> Self
pub fn new(url: impl Into<String>) -> Self
Creates a new NATS configuration with the specified server URL.
pub fn with_subject(self, subject: impl Into<String>) -> Self
pub fn with_stream(self, stream: impl Into<String>) -> Self
pub fn with_deliver_policy(self, policy: NatsDeliverPolicy) -> Self
pub fn with_credentials( self, username: impl Into<String>, password: impl Into<String>, ) -> Self
Trait Implementations§
Source§impl Clone for NatsConfig
impl Clone for NatsConfig
Source§fn clone(&self) -> NatsConfig
fn clone(&self) -> NatsConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more