state execution
This commit is contained in:
parent
d6dba8e1f1
commit
b2a6ac19cb
@ -83,7 +83,7 @@ type WorkflowExecution struct {
|
||||
utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name)
|
||||
ExecDate *time.Time `json:"execution_date,omitempty" bson:"execution_date,omitempty" validate:"required"` // ExecDate is the execution date of the workflow, is required
|
||||
EndDate *time.Time `json:"end_date,omitempty" bson:"end_date,omitempty"` // EndDate is the end date of the workflow
|
||||
State int64 `json:"state" bson:"state" default:"0"` // State is the state of the workflow
|
||||
State ScheduledType `json:"state" bson:"state" default:"0"` // State is the state of the workflow
|
||||
WorkflowID string `json:"workflow_id" bson:"workflow_id,omitempty"` // WorkflowID is the ID of the workflow
|
||||
}
|
||||
|
||||
@ -96,13 +96,13 @@ func (wfa *WorkflowExecution) ArgoStatusToState(status string) *WorkflowExecutio
|
||||
status = strings.ToLower(status)
|
||||
switch status {
|
||||
case "succeeded": // Succeeded
|
||||
wfa.State = int64(SUCCESS.EnumIndex())
|
||||
wfa.State = SUCCESS
|
||||
case "pending": // Pending
|
||||
wfa.State = int64(SCHEDULED.EnumIndex())
|
||||
wfa.State = SCHEDULED
|
||||
case "running": // Running
|
||||
wfa.State = int64(STARTED.EnumIndex())
|
||||
wfa.State = STARTED
|
||||
default: // Failed
|
||||
wfa.State = int64(FAILURE.EnumIndex())
|
||||
wfa.State = FAILURE
|
||||
}
|
||||
return wfa
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ func (wfa *workflowExecutionMongoAccessor) LoadOne(id string) (utils.DBObject, i
|
||||
}
|
||||
res_mongo.Decode(&workflow)
|
||||
fmt.Println("workflow: ", workflow.State, time.Now().UTC().After(*workflow.ExecDate))
|
||||
if workflow.State == int64(SCHEDULED) && time.Now().UTC().After(*workflow.ExecDate) {
|
||||
workflow.State = int64(FORGOTTEN)
|
||||
if workflow.State == SCHEDULED && time.Now().UTC().After(*workflow.ExecDate) {
|
||||
workflow.State = FORGOTTEN
|
||||
wfa.UpdateOne(&workflow, id)
|
||||
}
|
||||
return &workflow, 200, nil
|
||||
|
Loading…
Reference in New Issue
Block a user