pub struct MongoDbConfig {Show 22 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 consume: Option<MongoConsume>,
pub receive_query: Option<String>,
pub change_stream: bool,
pub checkpoint_store: Option<String>,
pub request_timeout_ms: Option<u64>,
pub ttl_seconds: Option<u64>,
pub capped_size_bytes: Option<i64>,
pub format: MongoDbFormat,
pub id_field: Option<String>,
pub report_outcome: bool,
pub cursor_id: Option<String>,
pub meta_collection: Option<String>,
pub shared: Option<bool>,
}Expand description
General MongoDB connection configuration.
Fields§
§url: StringMongoDB connection string URI. Can contain a comma-separated list of hosts for a replica set. If it contains userinfo, it will be treated as a secret.
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.
consume: Option<MongoConsume>(Consumer only) How to consume the collection: consumer (default, competing-consumers work
queue — destructive and ~5x slower), subscriber (ephemeral queue), capture_new (watch an
existing collection for changes), or capture_all (read existing documents first, then watch
for changes — use this for single-reader bulk reads and ETL). The bridge selects the
underlying mechanism automatically. If unset, the deprecated change_stream boolean is
honored for backward compatibility.
receive_query: Option<String>(Consumer only) Optional custom MongoDB query to filter messages. Provided as a JSON string (e.g., ‘{“type”: “notification”}’).
change_stream: bool(Consumer only) Deprecated — use consume: subscriber. Kept for compatibility.
checkpoint_store: Option<String>(Consumer only) Where to persist the resume cursor in capture_new/capture_all mode. A URL
selects the backend; a bare name (or /name) reuses the source database with that name:
- absent → source database, collection
mqb_cursors_<source_collection>(auto-unique) /my_cursors→ source database, collectionmy_cursorsfile:///var/lib/mqb/cursors.json→ local JSON file (read-only / write-restricted sources)mongodb://host/db/collection→ external MongoDB collection (collection optional)postgres://user@host/db/tableormysql://host/db/table→ external SQL table (table optional)s3://bucket/prefix(alsogs://,az://,abfs://) → cloud object store; creds via env
When no collection/table is named, it defaults to mqb_cursors_<source_collection>.
May embed connection credentials, so it is treated as a secret.
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.
id_field: Option<String>(Publisher only) Top-level payload field whose value becomes the document _id, for
idempotent inserts via the unique _id index. Sink collections only.
report_outcome: bool(Publisher only) Return the message with metadata mongodb.outcome = inserted/existed
(dup-key) so a request+switch can branch. Sink collections only; pair with id_field.
cursor_id: Option<String>The ID used for the cursor in sequenced mode. If not provided, consumption starts from the current sequence (ephemeral).
meta_collection: Option<String>(Optional) Collection to store sequence counters and cursor positions. Defaults to the message collection if not set.
Share one MongoDB client per connection (default: true); false forces a dedicated client.
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
Sourcepub fn resolved_consume(&self) -> MongoConsume
pub fn resolved_consume(&self) -> MongoConsume
The effective consume mode: the explicit consume field if set, otherwise derived from the
deprecated change_stream boolean.
Trait Implementations§
Source§impl Clone for MongoDbConfig
impl Clone for MongoDbConfig
Source§fn clone(&self) -> MongoDbConfig
fn clone(&self) -> MongoDbConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more