state execution
This commit is contained in:
parent
d6dba8e1f1
commit
b2a6ac19cb
@ -80,11 +80,11 @@ func (dma *WorkflowExecutions) Serialize() map[string]interface{} {
|
|||||||
* workflows generate their own executions
|
* workflows generate their own executions
|
||||||
*/
|
*/
|
||||||
type WorkflowExecution struct {
|
type WorkflowExecution struct {
|
||||||
utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name)
|
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
|
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
|
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
|
WorkflowID string `json:"workflow_id" bson:"workflow_id,omitempty"` // WorkflowID is the ID of the workflow
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wfa *WorkflowExecution) Equals(we *WorkflowExecution) bool {
|
func (wfa *WorkflowExecution) Equals(we *WorkflowExecution) bool {
|
||||||
@ -96,13 +96,13 @@ func (wfa *WorkflowExecution) ArgoStatusToState(status string) *WorkflowExecutio
|
|||||||
status = strings.ToLower(status)
|
status = strings.ToLower(status)
|
||||||
switch status {
|
switch status {
|
||||||
case "succeeded": // Succeeded
|
case "succeeded": // Succeeded
|
||||||
wfa.State = int64(SUCCESS.EnumIndex())
|
wfa.State = SUCCESS
|
||||||
case "pending": // Pending
|
case "pending": // Pending
|
||||||
wfa.State = int64(SCHEDULED.EnumIndex())
|
wfa.State = SCHEDULED
|
||||||
case "running": // Running
|
case "running": // Running
|
||||||
wfa.State = int64(STARTED.EnumIndex())
|
wfa.State = STARTED
|
||||||
default: // Failed
|
default: // Failed
|
||||||
wfa.State = int64(FAILURE.EnumIndex())
|
wfa.State = FAILURE
|
||||||
}
|
}
|
||||||
return wfa
|
return wfa
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,8 @@ func (wfa *workflowExecutionMongoAccessor) LoadOne(id string) (utils.DBObject, i
|
|||||||
}
|
}
|
||||||
res_mongo.Decode(&workflow)
|
res_mongo.Decode(&workflow)
|
||||||
fmt.Println("workflow: ", workflow.State, time.Now().UTC().After(*workflow.ExecDate))
|
fmt.Println("workflow: ", workflow.State, time.Now().UTC().After(*workflow.ExecDate))
|
||||||
if workflow.State == int64(SCHEDULED) && time.Now().UTC().After(*workflow.ExecDate) {
|
if workflow.State == SCHEDULED && time.Now().UTC().After(*workflow.ExecDate) {
|
||||||
workflow.State = int64(FORGOTTEN)
|
workflow.State = FORGOTTEN
|
||||||
wfa.UpdateOne(&workflow, id)
|
wfa.UpdateOne(&workflow, id)
|
||||||
}
|
}
|
||||||
return &workflow, 200, nil
|
return &workflow, 200, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user