refactor web pagination and add partitioned events, flap/timeout showcase agents

This commit is contained in:
Stanislav Rossovskii
2026-05-27 18:23:31 +04:00
parent d5f312f200
commit a2e88b4e76
46 changed files with 1600 additions and 742 deletions

View File

@@ -58,6 +58,20 @@ def _apply_migrations(database_url: str) -> Iterator[None]:
cfg.set_main_option("script_location", os.path.join(SERVER_ROOT, "alembic"))
cfg.set_main_option("sqlalchemy.url", get_settings().sync_database_url)
command.upgrade(cfg, "head")
# Partitions for `events` are created at runtime, not by the migration.
async def _bootstrap() -> None:
from sqlalchemy.ext.asyncio import create_async_engine
from monlet_server.services.partitioning import ensure_event_partitions
eng = create_async_engine(database_url, future=True)
try:
await ensure_event_partitions(eng)
finally:
await eng.dispose()
asyncio.run(_bootstrap())
yield
@@ -83,7 +97,7 @@ async def _truncate_tables(engine) -> AsyncIterator[None]:
async with engine.begin() as conn:
await conn.execute(
text(
"TRUNCATE TABLE notification_outbox, incidents, events, checks, agents RESTART IDENTITY CASCADE"
"TRUNCATE TABLE notification_outbox, incidents, events, event_ingest_dedup, checks, agents RESTART IDENTITY CASCADE"
)
)