@@ -428,11 +428,37 @@ func (workflow *Workflow) Invoke(r *Request) (ExecutionReport, error) {
428428 var err error
429429 requestId := ReqId (r .Id )
430430
431- progress := InitProgress (requestId , workflow )
432- pd := NewPartialData (requestId , workflow .Start .Next , "" , r .Params )
431+ var progress * Progress
432+ var pd * PartialData
433+
434+ // TODO: move into a function?
435+ if ! r .Resuming {
436+ progress = InitProgress (requestId , workflow )
437+ pd = NewPartialData (requestId , workflow .Start .Next , "" , r .Params )
438+ } else {
439+ var found bool
440+ progress , found = RetrieveProgress (requestId , true )
441+ if ! found {
442+ return ExecutionReport {}, fmt .Errorf ("failed to retrieve workflow progress: %v" , requestId )
443+ }
444+ if len (progress .ReadyToExecute ) == 0 {
445+ return ExecutionReport {}, fmt .Errorf ("workflow resumed but no task is ready for execution: %v" , requestId )
446+ } else if len (progress .ReadyToExecute ) > 1 {
447+ // TODO: manage case when len is > 1 (e.g., parallel branches)
448+ return ExecutionReport {}, fmt .Errorf ("workflow resumed with multiple tasks ready for execution not yet implemented!: %v" , requestId )
449+ }
450+
451+ pd , err = RetrieveSinglePartialData (requestId , progress .ReadyToExecute [0 ], true )
452+ if err != nil {
453+ return ExecutionReport {}, fmt .Errorf ("workflow resumed but unable to retrieve partial data of next task: %v" , requestId )
454+ }
455+ }
433456
434457 shouldContinue := true
435458 for shouldContinue {
459+ // TODO: introduce a workflow offloading policy
460+
461+ // TODO: if local execution:
436462 // executing workflow
437463 pd , progress , shouldContinue , err = workflow .Execute (r , pd , progress )
438464 if err != nil {
0 commit comments