class documentation
class Common(BaseSettings): (source)
Known subclasses: async_example_program.tools.configurator.Dev, async_example_program.tools.configurator.Prod
Common configuration parameters shared between all environments.
Read configuration parameters defined in this class, and from ENVIRONMENT variables and from the .env file.
- The source priority is changed to the following order:
- init_settings
- dotenv_settings
- env_settings
- file_secret_settings
- The following environment variables should already be defined:
- ENVIRONMENT (on all servers)
- HOSTNAME (on Linux servers only - set by OS)
- COMPUTERNAME (on Windows servers only - set by OS)
- The following secrets should already be defined:
- service_api_key
- mongo_url_{environment}
- rabbit_url_{environment}
- Path where your .env and <environment>.env file should be placed:
- linux: /home/<user>/.local
- darwin: /home/<user>/.local
- win32: C:Users<user>AppDataRoamingPython'
- Path where your secret files should be placed:
- linux: /home/<user>/.local/secrets
- darwin: /home/<user>/.local/secrets
- win32: C:Users<user>AppDataRoamingPythonsecrets'
You know you are running in Docker when the "/.dockerenv" file exists.
| Class Method | settings |
Moved dotenv_settings before env_settings and removed settings_cls since it causes recursion max depth error in this configuration. |
| Instance Variable | env |
Defined environment variable ENVIRONMENT. |
| Instance Variable | exchange |
RabbitMQ topic exchange name. |
| Instance Variable | log |
RabbitMQ link status log level mappings. |
| Instance Variable | model |
Fixed name used by the BaseSettings class. |
| Instance Variable | service |
Microservices API key. |
| Instance Variable | watch |
Messages that require the program name as part of the topic. |
| Property | server |
Return local server name stripped of possible domain part. |
@classmethod
def settings_customise_sources(cls, settings_cls:
def settings_customise_sources(cls, settings_cls:
Type[ BaseSettings], init_settings: PydanticBaseSettingsSource, env_settings: PydanticBaseSettingsSource, dotenv_settings: PydanticBaseSettingsSource, file_secret_settings: PydanticBaseSettingsSource) -> Tuple[ PydanticBaseSettingsSource, ...]:
(source)
¶
Moved dotenv_settings before env_settings and removed settings_cls since it causes recursion max depth error in this configuration.
overridden in
async_example_program.tools.configurator.Dev, async_example_program.tools.configurator.ProdFixed name used by the BaseSettings class.