pynenc_mongo.conf.config_mongo¶
Module Contents¶
Classes¶
Specific Configuration for any Mongo client. |
API¶
- class pynenc_mongo.conf.config_mongo.ConfigMongo(config_values: Optional[dict[str, Any]] = None, config_filepath: Optional[str] = None)[source]¶
Bases:
pynenc.conf.config_base.ConfigPynencBaseSpecific Configuration for any Mongo client.
This class provides configuration settings specific to Mongo clients, allowing for customization of the Mongo connection used in the system.
- Variables:
mongo_username (ConfigField[str]) – The username to use when connecting to the Mongo server. Defaults to an empty string, indicating that no username is provided.
mongo_password (ConfigField[str]) – The password to use when connecting to the Mongo server. Defaults to an empty string, indicating that no password is provided.
mongo_host (ConfigField[str]) – The hostname of the Mongo server. Defaults to ‘localhost’, specifying that the Mongo server is expected to be running on the same machine as the client.
mongo_port (ConfigField[int]) – The port number on which the Mongo server is listening. Defaults to 27017, which is the default port for Mongo.
mongo_db (ConfigField[str]) – The database name to connect to on the Mongo server. Defaults to ‘pynenc’,
mongo_url (ConfigField[str]) – The URL of the Mongo server. This field is intended to be used when the Mongo server is accessed via a URL rather than a hostname and port. Defaults to an empty string, indicating that no URL is provided. If specified will override all other connection parameters.
mongo_auth_source (ConfigField[str]) – The authentication source database for MongoDB. Defaults to an empty string, which means the default authentication database will be used. Set this if your MongoDB user is stored in a database other than the one you are connecting to.
mongo_pool_max_connections (ConfigField[int]) – The maximum number of connections allowed in the MongoDB connection pool. Defaults to 100.
socket_timeout (ConfigField[int]) – The socket timeout in seconds for MongoDB operations. Defaults to 10.
socket_connect_timeout (ConfigField[int]) – The connection timeout in seconds for establishing a MongoDB connection. Defaults to 10.
max_retries (ConfigField[int]) – The maximum number of retry attempts for MongoDB operations. Defaults to 3.
retry_base_delay (ConfigField[float]) – The base delay in seconds between retry attempts for MongoDB operations. Defaults to 0.1.
retry_max_delay (ConfigField[float]) – The maximum delay in seconds between retry attempts. Delays are capped at this value to prevent excessively long waits. Defaults to 60.0 (1 minute).
retry_max_time (ConfigField[float]) – The maximum total time in seconds to spend retrying before giving up. Defaults to 300.0 (5 minutes). This ensures the system keeps trying to reconnect for a reasonable period during temporary outages.
retry_indefinitely (ConfigField[bool]) – If True, retry indefinitely until connection is restored, ignoring max_retries and retry_max_time. Use with caution as this may block forever. Defaults to False.
chunk_threshold (ConfigField[int]) – The size threshold in bytes above which documents are compressed and stored as chunked documents instead of inline. This allows storing data larger than MongoDB’s 16MB BSON limit. Defaults to 15MB (15728640 bytes) to provide some safety margin.
Example usage of the
ConfigMongoclass involves initializing it with specific values for host, port, database, or authentication source, or relying on the defaults for a standard Mongo setup.Initialization
- mongo_username¶
‘ConfigField(…)’
- mongo_password¶
‘ConfigField(…)’
- mongo_host¶
‘ConfigField(…)’
- mongo_port¶
‘ConfigField(…)’
- mongo_db¶
‘ConfigField(…)’
- mongo_url¶
‘ConfigField(…)’
- mongo_auth_source¶
‘ConfigField(…)’
- mongo_pool_max_connections¶
‘ConfigField(…)’
- socket_timeout¶
‘ConfigField(…)’
- socket_connect_timeout¶
‘ConfigField(…)’
- max_retries¶
‘ConfigField(…)’
- retry_base_delay¶
‘ConfigField(…)’
- retry_max_delay¶
‘ConfigField(…)’
- retry_max_time¶
‘ConfigField(…)’
- retry_indefinitely¶
‘ConfigField(…)’
- chunk_threshold¶
‘ConfigField(…)’