refactor: decompose monitor.go and sqlstore.go into focused files #154

Merged
lerko merged 1 commits from refactor/decompose-monitor-sqlstore into main 2026-06-27 23:29:11 +00:00
Owner

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 pipeline
  • checks.go (315 lines) — monitoring loop, push/group checks, probe ingestion, heartbeat
  • sites.go (158 lines) — live state management, token index, pause/active control
  • maintenance.go (70 lines) — maintenance cache, pruner goroutine

sqlstore.go (833 → 470 lines) — extracted 3 files:

  • sqlstore_alerts.go (126 lines) — alert CRUD + settings marshal/unmarshal
  • sqlstore_history.go (116 lines) — check history + state changes + pruning
  • sqlstore_maintenance.go (148 lines) — maintenance window CRUD + overlap + pruning

Tests 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 green
  • golangci-lint run ./... 0 issues
  • go build ./... clean
  • No behavioral changes — pure file reorganization
## 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 pipeline - `checks.go` (315 lines) — monitoring loop, push/group checks, probe ingestion, heartbeat - `sites.go` (158 lines) — live state management, token index, pause/active control - `maintenance.go` (70 lines) — maintenance cache, pruner goroutine **sqlstore.go** (833 → 470 lines) — extracted 3 files: - `sqlstore_alerts.go` (126 lines) — alert CRUD + settings marshal/unmarshal - `sqlstore_history.go` (116 lines) — check history + state changes + pruning - `sqlstore_maintenance.go` (148 lines) — maintenance window CRUD + overlap + pruning Tests move with their implementation. No file exceeds 500 lines. Pure reorganization — no behavioral changes, no new types, no API changes. ## Test plan - [x] `go test ./...` all green - [x] `golangci-lint run ./...` 0 issues - [x] `go build ./...` clean - [x] No behavioral changes — pure file reorganization
lerko added 1 commit 2026-06-27 23:23:42 +00:00
refactor: decompose monitor.go and sqlstore.go into focused files
CI / test (pull_request) Successful in 1m44s
CI / lint (pull_request) Successful in 1m11s
CI / vulncheck (pull_request) Successful in 56s
8f16a09da1
Split monitor.go (1131→350 lines) into alerts.go, checks.go,
sites.go, and maintenance.go by concern. Split sqlstore.go
(833→470 lines) into sqlstore_alerts.go, sqlstore_history.go,
and sqlstore_maintenance.go by domain. Tests move with their
implementation. Pure reorganization — no behavioral changes.
lerko force-pushed refactor/decompose-monitor-sqlstore from 9eaddbb6e8 to 8f16a09da1 2026-06-27 23:23:42 +00:00 Compare
lerko merged commit 8f16a09da1 into main 2026-06-27 23:29:11 +00:00
lerko deleted branch refactor/decompose-monitor-sqlstore 2026-06-27 23:29:11 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: lerkolabs/uptop#154