Files
Agent-System/internal/supplementimpact/trigger.go
T
weichen 4e0e6a1418 feat(notification): digest aggregates, supplement-impact batch, and free-collab hooks
Add notification digests with ON CONFLICT DO UPDATE, migrations 00068-00070,
supplementimpact module (analyze → confirm → claim-aware split), and wire
coordinator/mutate hooks plus proposal_required digests.
2026-09-24 11:44:20 +00:00

29 lines
855 B
Go

package supplementimpact
import (
"context"
"log/slog"
"time"
)
// TriggerAsync kicks CreateFromSupplement in a background goroutine with panic recovery
// so chat / mutate paths are never blocked by impact analysis.
func TriggerAsync(svc *Service, projectID, userID int64, sessionID, summary, markdown string) {
if svc == nil {
return
}
go func() {
defer func() {
if rec := recover(); rec != nil {
slog.Error("supplementimpact: TriggerAsync panic", "recover", rec, "project_id", projectID)
}
}()
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()
if _, err := svc.CreateFromSupplement(ctx, projectID, userID, sessionID, summary, markdown); err != nil {
slog.Warn("supplementimpact: CreateFromSupplement failed",
"project_id", projectID, "user_id", userID, "error", err)
}
}()
}