Skip to content
GitHubRSS

Core Configuration

The core configuration file (config/brotr.yaml) controls the database connection pool, batch processing parameters, and timeout values shared across all services.

config/brotr.yaml
pool:
dsn: postgresql://writer:password@pgbouncer:5432/bigbrotr
min_size: 2
max_size: 10
max_inactive_connection_lifetime: 300
batch:
max_size: 1000
timeouts:
query: 60 # seconds for individual queries
batch: 120 # seconds for batch operations
cleanup: 90 # seconds for cleanup operations
refresh: null # null = no timeout for materialized view refresh

The PoolConfig controls the asyncpg connection pool:

ParameterDefaultDescription
dsnPostgreSQL connection string
min_size2Minimum pool connections
max_size10Maximum pool connections
max_inactive_connection_lifetime300Seconds before idle connections are closed

The pool includes automatic retry with exponential backoff for transient connection failures. Health checks verify connection viability before use.

Controls batch sizes for database operations:

ParameterDefaultDescription
max_size1000Maximum items per batch operation (1–100,000)

Centralized timeouts prevent runaway queries:

ParameterDefaultDescription
query60Per-query timeout in seconds
batch120Batch operation timeout
cleanup90Cleanup operation timeout
refreshnullMaterialized view refresh timeout (null = unlimited)

Timeouts are config-driven — query functions in services/common/queries.py never accept timeout parameters directly. They read from TimeoutsConfig.

The DSN (Data Source Name) uses the standard PostgreSQL format:

postgresql://user:password@host:port/database

In Docker deployments, services connect through PgBouncer:

pool:
dsn: postgresql://writer:${WRITER_PASSWORD}@pgbouncer:5432/bigbrotr