refactor(db): thread context.Context through all Store methods

Enables request-scoped cancellation, timeouts, and graceful shutdown
for all database operations across API handlers, CLI commands, and TUI.
This commit is contained in:
2026-05-20 20:51:51 -04:00
parent 50b80f4407
commit d715b053e7
18 changed files with 267 additions and 228 deletions
+4 -4
View File
@@ -19,19 +19,19 @@ func init() {
rootCmd.AddCommand(copyCmd)
}
func runCopy(_ *cobra.Command, args []string) error {
func runCopy(cmd *cobra.Command, args []string) error {
store, err := openStore()
if err != nil {
return err
}
defer store.Close()
id, err := store.Resolve(args[0])
id, err := store.Resolve(cmd.Context(), args[0])
if err != nil {
return fmt.Errorf("not_found — no entity with id %s", args[0])
}
e, err := store.Get(id)
e, err := store.Get(cmd.Context(), id)
if err != nil {
return err
}
@@ -40,7 +40,7 @@ func runCopy(_ *cobra.Command, args []string) error {
return fmt.Errorf("clipboard: %w", err)
}
if err := store.IncrementUse(id); err != nil {
if err := store.IncrementUse(cmd.Context(), id); err != nil {
return err
}