Skip to content

Конфигурация

Bases: BaseSettings

Server application settings.

The settings can be passed in several ways:

  1. By storing settings in a configuration file config.yml (preferred).
  2. By setting environment variables matching specific keys (SYNCMASTER__DATABASE__URL == database.url).
  3. By explicitly passing a settings object as an argument of application factory function.

More details can be found in Pydantic documentation <https://docs.pydantic.dev/latest/concepts/pydantic_settings/>_.

Examples

.. code-block:: yaml :caption: config.yml

database:
    url: postgresql+asyncpg://postgres:postgres@localhost:5432/syncmaster

broker:
    url: amqp://user:password@localhost:5672/

logging: {}
encryption: {}
server: {}
auth: {}
Source code in syncmaster/server/settings/__init__.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class ServerAppSettings(BaseSettings):
    """Server application settings.

    The settings can be passed in several ways:

    1. By storing settings in a configuration file ``config.yml`` (preferred).
    2. By setting environment variables matching specific keys (``SYNCMASTER__DATABASE__URL`` == ``database.url``).
    3. By explicitly passing a settings object as an argument of application factory function.

    More details can be found in
    `Pydantic documentation <https://docs.pydantic.dev/latest/concepts/pydantic_settings/>`_.

    Examples
    --------

    .. code-block:: yaml
        :caption: config.yml

        database:
            url: postgresql+asyncpg://postgres:postgres@localhost:5432/syncmaster

        broker:
            url: amqp://user:password@localhost:5672/

        logging: {}
        encryption: {}
        server: {}
        auth: {}
    """

    database: DatabaseSettings = Field(
        default_factory=DatabaseSettings,  # type: ignore[arg-type]
        description=":ref:`Database settings <server-configuration-database>`",
    )
    broker: RabbitMQSettings = Field(
        default_factory=RabbitMQSettings,  # type: ignore[arg-type]
        description=":ref:`Broker settings <server-configuration-broker>`",
    )
    logging: LoggingSettings = Field(
        default=DEFAULT_LOGGING_SETTINGS,
        description=":ref:`Logging settings <server-configuration-logging>`",
    )
    server: ServerSettings = Field(
        default_factory=ServerSettings,
        description=":ref:`Server settings <server-configuration>`",
    )
    auth: AuthSettings = Field(
        default_factory=AuthSettings,
        description=":ref:`Auth provider settings <server-auth-providers>`",
    )
    encryption: CredentialsEncryptionSettings = Field(
        default_factory=CredentialsEncryptionSettings,  # type: ignore[arg-type]
        description="Settings for encrypting credential data",
    )

Bases: BaseModel

Server server settings.

Examples

.. code-block:: yaml :caption: config.yml

server:
    debug: true
    request_id:
        enabled: true
    cors:
        enabled: true
    monitoring:
        enabled: true
    openapi:
        enabled: true
    static_files:
        enabled: true
Source code in syncmaster/server/settings/server/__init__.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
class ServerSettings(BaseModel):
    """Server server settings.

    Examples
    --------

    .. code-block:: yaml
        :caption: config.yml

        server:
            debug: true
            request_id:
                enabled: true
            cors:
                enabled: true
            monitoring:
                enabled: true
            openapi:
                enabled: true
            static_files:
                enabled: true
    """

    debug: bool = Field(
        default=False,
        description=textwrap.dedent(
            """
            :ref:`Enable debug output in responses <server-configuration-debug>`.
            Do not use this on production!
            """,
        ),
    )
    request_id: RequestIDSettings = Field(
        default_factory=RequestIDSettings,
    )
    cors: CORSSettings = Field(
        default_factory=CORSSettings,
        description=":ref:`CORS settings <server-configuration-cors>`",
    )
    monitoring: MonitoringSettings = Field(
        default_factory=MonitoringSettings,
        description=":ref:`Monitoring settings <server-configuration-monitoring>`",
    )
    openapi: OpenAPISettings = Field(
        default_factory=OpenAPISettings,
        description=":ref:`OpenAPI.json settings <server-configuration-openapi>`",
    )
    static_files: StaticFilesSettings = Field(
        default_factory=StaticFilesSettings,
        description=":ref:`Static files settings <server-configuration-static-files>`",
    )