state execution

This commit is contained in:
mr 2024-11-12 12:17:30 +01:00
parent d6dba8e1f1
commit b2a6ac19cb
2 changed files with 11 additions and 11 deletions

View File

@ -80,11 +80,11 @@ func (dma *WorkflowExecutions) Serialize() map[string]interface{} {
* workflows generate their own executions
*/
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
WorkflowID string `json:"workflow_id" bson:"workflow_id,omitempty"` // WorkflowID is the ID of the workflow
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 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
}
func (wfa *WorkflowExecution) Equals(we *WorkflowExecution) bool {
@ -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
}

View File

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