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:
+4
-4
@@ -19,19 +19,19 @@ func init() {
|
||||
rootCmd.AddCommand(absorbCmd)
|
||||
}
|
||||
|
||||
func runAbsorb(_ *cobra.Command, args []string) error {
|
||||
func runAbsorb(cmd *cobra.Command, args []string) error {
|
||||
store, err := openStore()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer store.Close()
|
||||
|
||||
targetID, err := store.Resolve(args[0])
|
||||
targetID, err := store.Resolve(cmd.Context(), args[0])
|
||||
if err != nil {
|
||||
return fmt.Errorf("not_found — no entity with id %s", args[0])
|
||||
}
|
||||
|
||||
sourceID, err := store.Resolve(args[1])
|
||||
sourceID, err := store.Resolve(cmd.Context(), args[1])
|
||||
if err != nil {
|
||||
return fmt.Errorf("not_found — no entity with id %s", args[1])
|
||||
}
|
||||
@@ -40,7 +40,7 @@ func runAbsorb(_ *cobra.Command, args []string) error {
|
||||
return fmt.Errorf("target and source must be different entities")
|
||||
}
|
||||
|
||||
if err := store.Absorb(targetID, sourceID); err != nil {
|
||||
if err := store.Absorb(cmd.Context(), targetID, sourceID); err != nil {
|
||||
if err == db.ErrTargetCrystallized {
|
||||
return fmt.Errorf("invalid_absorb — target %s is crystallized, demote first",
|
||||
display.FormatID(targetID))
|
||||
|
||||
Reference in New Issue
Block a user