|
|
|
@ -69,7 +69,38 @@ func (ms *mongoStorage) Workflow(id string, mustExist bool) (*jw.Workflow, error
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (ms *mongoStorage) UpdateWorkflow(wf *jw.Workflow, job, nextJob *jw.Job) error { |
|
|
|
|
return errors.NotImplemented() |
|
|
|
|
ctx, cancel := util.CtxWithTimeout(5 * time.Second) |
|
|
|
|
defer cancel() |
|
|
|
|
|
|
|
|
|
session, err := ms.client.StartSession() |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
defer session.EndSession(ctx) |
|
|
|
|
|
|
|
|
|
_, err = session.WithTransaction( |
|
|
|
|
ctx, |
|
|
|
|
func(ctx mongo.SessionContext) (interface{}, error) { |
|
|
|
|
if err := ms.txUpdateJob(ctx, job); err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if wf != nil { |
|
|
|
|
if err := ms.cWorkflows().FindOneAndReplace(ctx, bson.M{"_id": wf.ID}, wf).Err(); err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if nextJob == nil { |
|
|
|
|
return nil, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return nil, ms.txInsertJob(ctx, nextJob) |
|
|
|
|
}, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (ms *mongoStorage) SetWorkflowPriority(id string, priority jw.Priority) error { |
|
|
|
|