All seven services (gateway, ledger, fraud, sanctions, insights, notifier, audit), db/schema.sql plus optional_indexes.sql, scripts/seed.py and smoke.py, the gateway-served frontend, and docker-compose.yml. Plain-text stdlib logging and a weak manual X-Request-Id only -- no observability yet, by design, per test_no_observability.py. Implements all 13 named chaos-flag pathologies from docs/PATHOLOGIES.md behind Redis-backed runtime flags. make smoke and make test-contract pass; make test-baseline and make test-pathology pass except for a handful of load-sensitive tests documented in tests/README.md rather than papered over.
18 lines
755 B
Python
18 lines
755 B
Python
"""Two pre-built engines so pool_starvation (phase-0-base-project-spec.md §7)
|
|
can be toggled live, with no restart: the flag picks which already-initialised
|
|
pool a request borrows a connection from, rather than resizing a pool in
|
|
place (SQLAlchemy pools aren't resizable live)."""
|
|
from sqlalchemy.ext.asyncio import async_sessionmaker
|
|
|
|
from common.db import make_engine
|
|
|
|
normal_engine = make_engine(pool_size=20, max_overflow=10)
|
|
starved_engine = make_engine(pool_size=2, max_overflow=0, pool_timeout=10)
|
|
|
|
NormalSession = async_sessionmaker(normal_engine, expire_on_commit=False)
|
|
StarvedSession = async_sessionmaker(starved_engine, expire_on_commit=False)
|
|
|
|
|
|
def session_factory(starved: bool):
|
|
return StarvedSession() if starved else NormalSession()
|