pub struct MongoDbConfig {Show 15 fields
pub url: String,
pub collection: Option<String>,
pub username: Option<String>,
pub password: Option<String>,
pub tls: TlsConfig,
pub database: String,
pub polling_interval_ms: Option<u64>,
pub reply_polling_ms: Option<u64>,
pub request_reply: bool,
pub change_stream: bool,
pub request_timeout_ms: Option<u64>,
pub ttl_seconds: Option<u64>,
pub capped_size_bytes: Option<i64>,
pub format: MongoDbFormat,
pub cursor_id: Option<String>,
}Expand description
General MongoDB connection configuration.
Fields§
§url: StringMongoDB connection string URI. Can contain a comma-separated list of hosts for a replica set.
Credentials provided via the separate username and password fields take precedence over any credentials embedded in the URL.
collection: Option<String>The MongoDB collection name.
username: Option<String>Optional username. Takes precedence over any credentials embedded in the url.
Use embedded URL credentials for simple one-off connections but prefer explicit username/password fields (or environment-sourced secrets) for clarity and secret management in production.
password: Option<String>Optional password. Takes precedence over any credentials embedded in the url.
Use embedded URL credentials for simple one-off connections but prefer explicit username/password fields (or environment-sourced secrets) for clarity and secret management in production.
tls: TlsConfigTLS configuration.
database: StringThe database name.
polling_interval_ms: Option<u64>(Consumer only) Polling interval in milliseconds for the consumer (when not using Change Streams). Defaults to 100ms.
reply_polling_ms: Option<u64>(Publisher only) Polling interval in milliseconds for the publisher when waiting for a reply. Defaults to 50ms.
request_reply: bool(Publisher only) If true, the publisher will wait for a response in a dedicated collection. Defaults to false.
change_stream: bool(Consumer only) If true, use Change Streams (Subscriber mode). Defaults to false (polling/consumer mode).
request_timeout_ms: Option<u64>(Publisher only) Timeout for request-reply operations in milliseconds. Defaults to 30000ms.
ttl_seconds: Option<u64>(Publisher only) TTL in seconds for documents created by the publisher. If set, a TTL index is created.
capped_size_bytes: Option<i64>(Publisher only) If set, creates a capped collection with this size in bytes.
format: MongoDbFormatFormat for storing messages. Defaults to Normal.
cursor_id: Option<String>The ID used for the cursor in sequenced mode. If not provided, consumption starts from the current sequence (ephemeral).
Implementations§
Source§impl MongoDbConfig
impl MongoDbConfig
Sourcepub fn new(url: impl Into<String>, database: impl Into<String>) -> Self
pub fn new(url: impl Into<String>, database: impl Into<String>) -> Self
Creates a new MongoDB configuration with the specified URL and database name.
pub fn with_collection(self, collection: impl Into<String>) -> Self
pub fn with_credentials( self, username: impl Into<String>, password: impl Into<String>, ) -> Self
pub fn with_change_stream(self, change_stream: bool) -> Self
Trait Implementations§
Source§impl Clone for MongoDbConfig
impl Clone for MongoDbConfig
Source§fn clone(&self) -> MongoDbConfig
fn clone(&self) -> MongoDbConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more