feat: persist workflow controls and settle stopped branches
This commit is contained in:
@@ -187,7 +187,9 @@ func (r *WorkflowRuntime) consume(ctx context.Context, tx *sql.Tx, g *workflowGr
|
||||
}
|
||||
}
|
||||
// 单轮请求失败不能通过新建业务轮次绕过Pulse预算。
|
||||
if state != weave.StepSucceeded {
|
||||
if g.view.StopKind != nil && (state == weave.StepCancelled || state == weave.StepFailed) {
|
||||
reason = "POLL_STOP_REQUEST_SETTLED"
|
||||
} else if state != weave.StepSucceeded {
|
||||
state, reason = weave.StepNeedsReview, "POLL_REQUEST_REVIEW"
|
||||
} else if !source.occurred.Before(deadline) {
|
||||
state, output, reason = weave.StepNeedsReview, nil, "POLL_DEADLINE"
|
||||
@@ -198,7 +200,9 @@ func (r *WorkflowRuntime) consume(ctx context.Context, tx *sql.Tx, g *workflowGr
|
||||
state, output, reason = weave.StepNeedsReview, nil, "POLL_RESULT_INVALID"
|
||||
case outcome == engine.PollPending:
|
||||
state, output, reason = weave.StepWaiting, nil, "POLL_PENDING"
|
||||
if used >= max {
|
||||
if g.view.StopKind != nil {
|
||||
state, reason = weave.StepCancelled, "POLL_STOP_PENDING_SETTLED"
|
||||
} else if used >= max {
|
||||
state, reason = weave.StepNeedsReview, "POLL_ROUNDS_EXHAUSTED"
|
||||
}
|
||||
case outcome == engine.PollFailed:
|
||||
@@ -250,7 +254,7 @@ func (r *WorkflowRuntime) consume(ctx context.Context, tx *sql.Tx, g *workflowGr
|
||||
}
|
||||
if state == weave.StepNeedsReview || state == weave.StepFailed || state == weave.StepCancelled {
|
||||
next := weave.InstanceNeedsReview
|
||||
if (state == weave.StepFailed || state == weave.StepCancelled) && (g.version.Specification.FailurePolicy == "FAIL_AFTER_SETTLED" || g.view.CancelRequestedAt != nil) {
|
||||
if (state == weave.StepFailed || state == weave.StepCancelled) && (g.view.StopKind != nil || g.version.Specification.FailurePolicy == "FAIL_AFTER_SETTLED" || g.view.CancelRequestedAt != nil) {
|
||||
next = weave.InstanceCancelling
|
||||
}
|
||||
if err := holdWorkflow(ctx, tx, g, next, reason, now); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user