Use a new context for the next step, because the current one of the job is already stopped
This commit is contained in:
@@ -38,7 +38,8 @@ func NewStep(params *StepParams) *Step {
|
||||
NextSteps: make(map[string]*Step),
|
||||
}
|
||||
step.Queue = queue.NewGeneralQueue(params.Identifier,
|
||||
params.Client, step.HandleQueue, params.Processors)
|
||||
params.Client, step.HandleQueue, params.Processors,
|
||||
queue.WithAutoStop(true))
|
||||
return &step
|
||||
}
|
||||
|
||||
@@ -49,7 +50,7 @@ func (s *Step) AddNextStep(step *Step) {
|
||||
const workflowIdParam = "workflowId"
|
||||
|
||||
func (s *Step) Execute(ctx context.Context, payload map[string]any) error {
|
||||
ersteller.Debug("Executing step '%s'", s.Name, "payload", payload)
|
||||
ersteller.Debug("Executing step ", s.Name, "payload", payload)
|
||||
_, err := s.Queue.Enqueue(ctx, payload, s.MaxRetries, -1, queue.WithWorkflowId(payload[workflowIdParam].(string)))
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -67,7 +68,7 @@ func (s *Step) HandleQueue(ctx context.Context, job queue.GeneralQueueJob) (queu
|
||||
if nextStep != nil {
|
||||
result.ResultPayload[workflowIdParam] = workflowId
|
||||
ersteller.Debug("Moving to next step ", nextStep.Name, "payload", result.ResultPayload)
|
||||
err = nextStep.Execute(ctx, result.ResultPayload)
|
||||
err = nextStep.Execute(context.Background(), result.ResultPayload)
|
||||
if err != nil {
|
||||
failurePayload := result.FailurePayload
|
||||
failurePayload["next_step_error"] = fmt.Sprint("Failed to execute next step: ", err.Error())
|
||||
@@ -88,6 +89,9 @@ type Workflow struct {
|
||||
}
|
||||
|
||||
func NewWorkflow(name string, identifier string, firstStep *Step, allSteps []*Step) *Workflow {
|
||||
for _, step := range allSteps {
|
||||
step.Identifier = identifier + "_" + step.Name
|
||||
}
|
||||
return &Workflow{
|
||||
Name: name,
|
||||
FirstStep: firstStep,
|
||||
|
||||
Reference in New Issue
Block a user