refactor: propagate context.Context through call chains
CI / test (pull_request) Successful in 1m56s
CI / lint (pull_request) Successful in 1m17s
CI / vulncheck (pull_request) Successful in 56s

Thread context.Context from callers instead of creating
context.Background() at every call site. Engine stores its
lifecycle ctx for use by triggerAlert goroutines. TUI Model
carries ctx for store operations in Cmd closures. CLI commands
create a root ctx and thread it through openStore, seed
functions, and init methods.

Only two intentional context.Background() remain in non-root
positions: engine constructor default (overridden by Start)
and drainWrites (parent already cancelled at shutdown).
This commit was merged in pull request #155.
This commit is contained in:
2026-06-27 19:43:44 -04:00
parent 8f16a09da1
commit a5fd3aec90
14 changed files with 108 additions and 89 deletions
+3 -3
View File
@@ -1,7 +1,6 @@
package tui
import (
"context"
"fmt"
neturl "net/url"
"sort"
@@ -537,15 +536,16 @@ func (m *Model) submitAlertForm() tea.Cmd {
}
st := m.store
ctx := m.ctx
id := m.editID
name, aType := d.Name, d.AlertType
m.state = stateDashboard
if id > 0 {
return writeCmd("Update alert", func() error {
return st.UpdateAlert(context.Background(), id, name, aType, settings)
return st.UpdateAlert(ctx, id, name, aType, settings)
})
}
return writeCmd("Add alert", func() error {
return st.AddAlert(context.Background(), name, aType, settings)
return st.AddAlert(ctx, name, aType, settings)
})
}