feat: consume workflow results and resume durable advances

This commit is contained in:
2026-09-18 02:21:30 +08:00
parent 553a0bf522
commit f602a5ee05
15 changed files with 1458 additions and 15 deletions

View File

@@ -81,6 +81,31 @@ func run() error {
}
httpserver.RegisterSchedules(server, schedule.New(schedules))
httpserver.RegisterWorkflowDefinitions(server, definition.New(mysql.NewWorkflowDefinitionStore(db)))
workflows, err := mysql.NewWorkflowRuntime(db, node)
if err != nil {
return err
}
workflowCtx, stopWorkflows := context.WithCancel(root)
workflowDone := make(chan struct{})
go func() {
defer close(workflowDone)
ticker := time.NewTicker(time.Second)
defer ticker.Stop()
for {
select {
case <-workflowCtx.Done():
return
case <-ticker.C:
call, cancel := context.WithTimeout(workflowCtx, 5*time.Second)
_, err := workflows.Tick(call, 100)
cancel()
if err != nil && workflowCtx.Err() == nil {
slog.Error("workflow batch failed", "node_id", node)
}
}
}
}()
defer func() { stopWorkflows(); <-workflowDone }()
scheduleCtx, stopSchedules := context.WithCancel(root)
scheduleDone := make(chan struct{})
go func() {