MongoDB
The MongoDB client as a store, and how the URI scheme decides whether the module can start lazily.
ulo-db-mongodb binds mongodb::Client. MongoDB has no migrator, so the module has no .migrate(..).
use ulo_db_mongodb::MongoModule;
m.import(MongoModule::from_config(&config, "mongo"));Options
| Key | Meaning |
|---|---|
uri | mongodb:// or mongodb+srv://. A Secret. The key is uri, not url. |
max_pool_size | Optional. |
min_pool_size | Optional. |
app_name | Optional. |
The scheme decides the start
Whether creating the client connects depends on the URI. Client::with_options connects nothing, but parsing a mongodb+srv URI resolves its DNS inside create.
| URI | create | Start | .lazy() |
|---|---|---|---|
mongodb:// | Resolves nothing. | The ping retries under connect_within. | Offered. |
mongodb+srv:// | Resolves DNS, retried by ulo-db's loop under connect_within. | One confirming ping after the loop. | Refused at wire(), naming the scheme. |
wire() checks the scheme and a host and does no lookup, since validation must not touch the network.
MongoDB has no unknown-database error, because it creates a database on first write. A database named in the URL with no authSource becomes the authentication source and fails as an authentication error, which is permanent.
Authentication cost
The driver derives a SCRAM key on the thread that polls the connect, and the store leaves it there. Against a server with a root user and --auth, the longest gap between two ticks of a 5 ms ticker on a one-thread runtime was a median of 7.1 ms in a release build and 78.0 ms in a debug build. A release build stays far inside a 50 ms bound. An application that runs a one-thread runtime in debug with authentication sees a stall of about 80 ms per connect. The cost is the driver's and not the store's.
No test exercises a TLS connection to MongoDB.