Skip to content

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

Settings

Bases: BaseSettings

Horizon backend settings.

Backend can be configured in 2 ways:

  • By explicitly passing settings object as an argument to :obj:application_factory <horizon.backend.main.application_factory>
  • By setting up environment variables matching a specific key.

    All environment variable names are written in uppercase and should be prefixed with HORIZON__. Nested items are delimited with __.

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

Examples

.. code-block:: bash

# same as settings.database.url = "postgresql+asyncpg://postgres:postgres@localhost:5432/horizon"
HORIZON__DATABASE__URL=postgresql+asyncpg://postgres:postgres@localhost:5432/horizon

# same as settings.server.debug = True
HORIZON__SERVER__DEBUG=True

# same as settings.auth.provider = horizon.backend.providers.auth.dummy.DummyAuthProvider
HORIZON__AUTH__PROVIDER=horizon.backend.providers.auth.dummy.DummyAuthProvider
Source code in horizon/backend/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
class Settings(BaseSettings):
    """Horizon backend settings.

    Backend can be configured in 2 ways:

    * By explicitly passing ``settings`` object as an argument to :obj:`application_factory <horizon.backend.main.application_factory>`
    * By setting up environment variables matching a specific key.

        All environment variable names are written in uppercase and should be prefixed with ``HORIZON__``.
        Nested items are delimited with ``__``.

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

    Examples
    --------

    .. code-block:: bash

        # same as settings.database.url = "postgresql+asyncpg://postgres:postgres@localhost:5432/horizon"
        HORIZON__DATABASE__URL=postgresql+asyncpg://postgres:postgres@localhost:5432/horizon

        # same as settings.server.debug = True
        HORIZON__SERVER__DEBUG=True

        # same as settings.auth.provider = horizon.backend.providers.auth.dummy.DummyAuthProvider
        HORIZON__AUTH__PROVIDER=horizon.backend.providers.auth.dummy.DummyAuthProvider
    """  # noqa: E501

    database: DatabaseSettings = Field(description=":ref:`Database settings <backend-configuration-database>`")
    server: ServerSettings = Field(
        default_factory=ServerSettings,
        description=":ref:`Server settings <backend-configuration>`",
    )
    auth: AuthSettings = Field(
        default_factory=AuthSettings,
        description=":ref:`Auth setting <backend-auth-providers>`",
    )

    class Config:
        env_prefix = "HORIZON__"
        env_nested_delimiter = "__"