feat(events): run notify side effects and ack on one fenced transaction
Shadow dry-runs the same handler then rolls back, writing only the intended digest. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -11,9 +11,12 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"chat-agent-system/internal/app/docnotify"
|
||||
"chat-agent-system/internal/config"
|
||||
"chat-agent-system/internal/db"
|
||||
"chat-agent-system/internal/docgov"
|
||||
"chat-agent-system/internal/events"
|
||||
"chat-agent-system/internal/notification"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
)
|
||||
@@ -57,6 +60,10 @@ func main() {
|
||||
|
||||
owner := fmt.Sprintf("events-%d", os.Getpid())
|
||||
disp := events.NewDispatcher(pool, cfg.Env, owner)
|
||||
notify := notification.NewService(pool)
|
||||
_ = disp.Register(events.ConsumerNotify, (&docnotify.EventConsumer{
|
||||
Notify: notify, Docs: docgov.NewGovernanceEngine(pool), Env: cfg.Env,
|
||||
}).HandleLease)
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("GET /health", func(w http.ResponseWriter, _ *http.Request) {
|
||||
writeJSON(w, http.StatusOK, map[string]any{"status": "ok", "env": cfg.Env, "owner": owner})
|
||||
|
||||
Reference in New Issue
Block a user