refactor: decompose monitor.go and sqlstore.go into focused files #154
Reference in New Issue
Block a user
Delete Branch "refactor/decompose-monitor-sqlstore"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Split the two largest files in the codebase into focused, single-concern modules.
monitor.go (1131 → 350 lines) — extracted 4 files:
alerts.go(272 lines) — AlertHealth struct, handleStatusChange state machine, alert pipelinechecks.go(315 lines) — monitoring loop, push/group checks, probe ingestion, heartbeatsites.go(158 lines) — live state management, token index, pause/active controlmaintenance.go(70 lines) — maintenance cache, pruner goroutinesqlstore.go (833 → 470 lines) — extracted 3 files:
sqlstore_alerts.go(126 lines) — alert CRUD + settings marshal/unmarshalsqlstore_history.go(116 lines) — check history + state changes + pruningsqlstore_maintenance.go(148 lines) — maintenance window CRUD + overlap + pruningTests move with their implementation. No file exceeds 500 lines. Pure reorganization — no behavioral changes, no new types, no API changes.
Test plan
go test ./...all greengolangci-lint run ./...0 issuesgo build ./...clean9eaddbb6e8to8f16a09da1