|
|
|
@ -12,6 +12,7 @@ import (
|
|
|
|
|
"forge.chapril.org/dune/jw" |
|
|
|
|
"forge.chapril.org/losyme/errors" |
|
|
|
|
"forge.chapril.org/losyme/util" |
|
|
|
|
"go.mongodb.org/mongo-driver/bson" |
|
|
|
|
"go.mongodb.org/mongo-driver/mongo" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
@ -46,7 +47,25 @@ func (ms *mongoStorage) InsertWorkflow(wf *jw.Workflow, job *jw.Job) error {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (ms *mongoStorage) Workflow(id string, mustExist bool) (*jw.Workflow, error) { |
|
|
|
|
return nil, errors.NotImplemented() |
|
|
|
|
ctx, cancel := util.CtxWithTimeout(5 * time.Second) |
|
|
|
|
defer cancel() |
|
|
|
|
|
|
|
|
|
wf := new(jw.Workflow) |
|
|
|
|
|
|
|
|
|
err := ms.cWorkflows().FindOne(ctx, bson.M{"_id": id}).Decode(wf) |
|
|
|
|
if err == nil { |
|
|
|
|
return wf, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if err != mongo.ErrNoDocuments { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if mustExist { |
|
|
|
|
return nil, errors.New("this workflow does not exist", "id", id) ///////////////////////////////////////////////
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return nil, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (ms *mongoStorage) UpdateWorkflow(wf *jw.Workflow, job, nextJob *jw.Job) error { |
|
|
|
|