Browse Source

En cours de développement

master
losyme 2 months ago
parent
commit
ee4d92c387
  1. 21
      internal/storage/mongo/workflows.go

21
internal/storage/mongo/workflows.go

@ -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 {

Loading…
Cancel
Save