feat: remove default timeout for both nodes and workflow (#585)

This commit is contained in:
shentongmartin
2025-08-05 20:42:01 +08:00
committed by GitHub
parent 90b561c3df
commit 4b3042359c
6 changed files with 209 additions and 89 deletions

View File

@@ -18,17 +18,14 @@ package execute
import (
"context"
"sync/atomic"
"time"
"github.com/coze-dev/coze-studio/backend/pkg/ctxcache"
)
const (
foregroundRunTimeout = 10 * time.Minute
backgroundRunTimeout = 24 * time.Hour
maxNodeCountPerWorkflow = 1000
maxNodeCountPerExecution = 1000
foregroundRunTimeout = 0 // timeout for workflow execution in foreground mode, 0 means no timeout
backgroundRunTimeout = 0 // timeout for workflow execution in background mode, 0 means no timeout
maxNodeCountPerWorkflow = 0 // maximum node count for a workflow, 0 means no limit
maxNodeCountPerExecution = 0 // maximum node count for a workflow execution, 0 means no limit
cancelCheckInterval = 200 * time.Millisecond
)
@@ -52,17 +49,17 @@ const (
executedNodeCountKey = "executed_node_count"
)
func IncrAndCheckExecutedNodes(ctx context.Context) (int64, bool) {
counter, ok := ctxcache.Get[atomic.Int64](ctx, executedNodeCountKey)
if !ok {
func IncrementAndCheckExecutedNodes(ctx context.Context) (int64, bool) {
exeCtx := GetExeCtx(ctx)
if exeCtx == nil {
return 0, false
}
current := counter.Add(1)
counter := exeCtx.executed
if counter == nil {
return 0, false
}
current := (*counter).Add(1)
return current, current > maxNodeCountPerExecution
}
func InitExecutedNodesCounter(ctx context.Context) context.Context {
ctxcache.Store(ctx, executedNodeCountKey, atomic.Int64{})
return ctx
}