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:
+3
-3
@@ -19,19 +19,19 @@ func init() {
|
||||
rootCmd.AddCommand(demoteCmd)
|
||||
}
|
||||
|
||||
func runDemote(_ *cobra.Command, args []string) error {
|
||||
func runDemote(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])
|
||||
}
|
||||
|
||||
if err := store.Demote(id); err != nil {
|
||||
if err := store.Demote(cmd.Context(), id); err != nil {
|
||||
if err == db.ErrAlreadyFluid {
|
||||
return fmt.Errorf("invalid_demote — entity %s is already fluid", display.FormatID(id))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user