workflow execution evolved
This commit is contained in:
parent
3ffff7d32c
commit
ad3293da9d
@ -247,15 +247,17 @@ func ToScheduler(m interface{}) (n *workflow_execution.WorkflowSchedule) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Request) Schedule(wfID string, scheduler *workflow_execution.WorkflowSchedule) (*workflow_execution.WorkflowSchedule, error) {
|
func (r *Request) Schedule(wfID string, scheduler *workflow_execution.WorkflowSchedule) (*workflow_execution.WorkflowSchedule, error) {
|
||||||
if _, _, err := scheduler.Schedules(wfID, &tools.APIRequest{
|
ws, _, _, err := scheduler.Schedules(wfID, &tools.APIRequest{
|
||||||
Caller: r.caller,
|
Caller: r.caller,
|
||||||
Username: r.user,
|
Username: r.user,
|
||||||
PeerID: r.peerID,
|
PeerID: r.peerID,
|
||||||
Groups: r.groups,
|
Groups: r.groups,
|
||||||
}); err != nil {
|
})
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return scheduler, nil
|
fmt.Println("BAM", ws)
|
||||||
|
return ws, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Request) CheckBooking(wfID string, start string, end string, durationInS float64, cron string) bool {
|
func (r *Request) CheckBooking(wfID string, start string, end string, durationInS float64, cron string) bool {
|
||||||
|
@ -87,21 +87,21 @@ func (ws *WorkflowSchedule) CheckBooking(wfID string, request *tools.APIRequest)
|
|||||||
return true, wf, execs, nil
|
return true, wf, execs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ws *WorkflowSchedule) Schedules(wfID string, request *tools.APIRequest) (*workflow.Workflow, []*WorkflowExecutions, error) {
|
func (ws *WorkflowSchedule) Schedules(wfID string, request *tools.APIRequest) (*WorkflowSchedule, *workflow.Workflow, []*WorkflowExecutions, error) {
|
||||||
if request == nil {
|
if request == nil {
|
||||||
return nil, []*WorkflowExecutions{}, errors.New("no request found")
|
return ws, nil, []*WorkflowExecutions{}, errors.New("no request found")
|
||||||
}
|
}
|
||||||
c := request.Caller
|
c := request.Caller
|
||||||
if c == nil || c.URLS == nil || c.URLS[tools.BOOKING] == nil {
|
if c == nil || c.URLS == nil || c.URLS[tools.BOOKING] == nil {
|
||||||
return nil, []*WorkflowExecutions{}, errors.New("no caller defined")
|
return ws, nil, []*WorkflowExecutions{}, errors.New("no caller defined")
|
||||||
}
|
}
|
||||||
methods := c.URLS[tools.BOOKING]
|
methods := c.URLS[tools.BOOKING]
|
||||||
if _, ok := methods[tools.GET]; !ok {
|
if _, ok := methods[tools.GET]; !ok {
|
||||||
return nil, []*WorkflowExecutions{}, errors.New("no path found")
|
return ws, nil, []*WorkflowExecutions{}, errors.New("no path found")
|
||||||
}
|
}
|
||||||
ok, wf, executions, err := ws.CheckBooking(wfID, request)
|
ok, wf, executions, err := ws.CheckBooking(wfID, request)
|
||||||
if !ok || err != nil {
|
if !ok || err != nil {
|
||||||
return nil, []*WorkflowExecutions{}, errors.New("could not book the workflow : " + fmt.Sprintf("%v", err))
|
return ws, nil, []*WorkflowExecutions{}, errors.New("could not book the workflow : " + fmt.Sprintf("%v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
ws.Workflow = wf
|
ws.Workflow = wf
|
||||||
@ -110,14 +110,14 @@ func (ws *WorkflowSchedule) Schedules(wfID string, request *tools.APIRequest) (*
|
|||||||
for _, exec := range executions {
|
for _, exec := range executions {
|
||||||
err := exec.PurgeDraft(request)
|
err := exec.PurgeDraft(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, []*WorkflowExecutions{}, errors.New("purge draft" + fmt.Sprintf("%v", err))
|
return ws, nil, []*WorkflowExecutions{}, errors.New("purge draft" + fmt.Sprintf("%v", err))
|
||||||
}
|
}
|
||||||
exec.GenerateID()
|
exec.GenerateID()
|
||||||
exec.StoreDraftDefault()
|
exec.StoreDraftDefault()
|
||||||
// Should DELETE the previous execution2
|
// Should DELETE the previous execution2
|
||||||
utils.GenericStoreOne(exec, NewAccessor(request))
|
utils.GenericStoreOne(exec, NewAccessor(request))
|
||||||
}
|
}
|
||||||
return wf, executions, nil
|
return ws, wf, executions, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user