Skip to main content

App Configuration

ArconQ allows you to override the configuration of applications running on its platform. Configuration values provided in ArconQ are automatically converted into environment variables, which your Python application can access.

To handle these environment variables effectively, we recommend using the Pydantic library. Pydantic simplifies configuration management by enabling you to define structured and type-safe configuration models. It also provides built-in support for reading environment variables, making it an excellent choice for managing configuration in applications running on ArconQ.

Additionally, the ArconQ Python SDK leverages Pydantic, ensuring seamless integration and consistency with the recommended approach.

Config example​

An example config in json form.

{
"SenderConfig": {
"ScheduledJobIntervalInSeconds": 1,
"AmountOfMessagesToSendAtOnce": 1,
"SendBiggerMessages": false,
"MessageSizeInMB": 1,
"PersistMessages": false
},
"TestConfig": {
"AreMetricsEnabled": true,
"IsLoggingEnabled": true
}
}

Mapping the config to classes using Pydantic​

AppConfig class which aggregates the 2 config sections

from pydantic import Field
from pydantic.alias_generators import to_pascal
from pydantic_settings import BaseSettings, SettingsConfigDict

from configuration.sender_config import SenderConfig
from configuration.test_config import TestConfig


class AppConfig(BaseSettings):
model_config = SettingsConfigDict(
env_nested_delimiter="__",
env_file=".env",
env_file_encoding="utf-8",
case_sensitive=False,
alias_generator=to_pascal,
)

senderConfig: SenderConfig = Field(default=SenderConfig())
testConfig: TestConfig = Field(default=TestConfig())

SenderConfig class

from pydantic import BaseModel, Field


class SenderConfig(BaseModel):
scheduledJobIntervalInSeconds: int = Field(default=1)
amountOfMessagesToSendAtOnce: int = Field(default=1)
sendBiggerMessages: bool = Field(default=False)
messageSizeInMB: float = Field(default=1.0)
persistMessages: bool = Field(default=False)

TestConfig class

from pydantic import BaseModel, Field


class TestConfig(BaseModel):
areMetricsEnabled: bool = Field(default=True)
isLoggingEnabled: bool = Field(default=True)