2.1 KiB
2.1 KiB
id, title, status, wave, depends_on, plan
| id | title | status | wave | depends_on | plan | ||
|---|---|---|---|---|---|---|---|
| task-07 | Health poller integration | pending | 2 |
|
docs/plans/plugins/plan.md |
Health poller integration
Title
Poll each active/error plugin's health endpoint on an interval and drive the state machine (active↔error), flushing buffered events on recovery.
Inputs
- Spec
docs/specs/plugins/requirements/plugins.md→ "State machine" health monitoring: every 30s,GET {base_url}{endpoints.health}must return 200 within 5s; 3 consecutive failures →error+ inbox item; next success →active+ flush buffered events in order. - Precedent:
internal/integrations/healthpoll(Prober/Poller, configurable interval). Either reusehealthpoll.New(name, prober, log)per plugin or write a dedicated small poller loop ininternal/plugins. Prefer a single loop that iterates all plugins every 30s (simpler than N pollers). - Interacts with task-05 Service (
SetStatus) and task-06 Deliverer (flush on recovery viaDeliverer.Flush(pluginID)— add that method in task-06 if missing; note it in your report so task-06 exposes it).
Acceptance
internal/plugins/health.go:HealthMonitorwithStart(ctx)/Stop(), 30s ticker (interval injectable for tests), 5s per-request timeout.- Tracks consecutive failures per plugin; 3 →
SetStatus(error); success from error →SetStatus(active)+Deliverer.Flush(id). - Updates
last_health_checkon the record via the Service/store. - Inbox item on transition to error: emit an event on the bus
(
plugin.health.degradedwith plugin id) OR call an injected notifier — pick the lighter option and document it. (Full office-inbox wiring is out of scope; emitting a bus event is sufficient.)
Files
apps/backend/internal/plugins/health.go+health_test.go(httptest server, injected short interval)
Verification
go test ./internal/plugins/...fromapps/backendmake -C apps/backend lint
Output contract
Report: single-loop vs per-plugin design chosen, transition thresholds, how recovery flush is triggered, and how the degraded notification is emitted.
Dependencies
task-05, task-06.