Example #1
0
func (e *Engine) finalizeMonitorChAfterExecute(mediators []stages.Mediator, mediator stages.Mediator) {
	// Append to monitorCh
	*e.MonitorCh <- mediator
	for _, m := range mediators {
		*e.MonitorCh <- m
	}

	// Set type
	if mediators[0].Type == "start" {
		log.Debug("Finalize monitor channel..")
		mediatorEnd := stages.Mediator{States: make(map[string]string), Type: "end"}
		*e.MonitorCh <- mediatorEnd
	} else {
		log.Debugf("Skipped finalizing")
	}
}
Example #2
0
func (e *Engine) waitAllChildStages(childStages *list.List, stage *stages.Stage) {
	for childStage := childStages.Front(); childStage != nil; childStage = childStage.Next() {
		s := childStage.Value.(stages.Stage)
		for {
			log.Debugf("Receiving child: %v", s.GetStageName())
			childReceived, ok := <-*s.GetOutputCh()
			if !ok {
				log.Debug("Closing child output")
				break
			}
			log.Debugf("Sending child: %v", childReceived)
			*(*stage).GetOutputCh() <- childReceived
			log.Debugf("Send child: %v", childReceived)
		}
		log.Debugf("Finished executing child: %v", s.GetStageName())
	}
}
Example #3
0
// ExecuteStage executes the supplied stage
func (e *Engine) ExecuteStage(stage stages.Stage) {
	log.Debug("Receiving input")
	mediatorsReceived := e.receiveInputs(stage.GetInputCh())

	log.Debugf("Received input size: %v", len(mediatorsReceived))
	log.Debugf("Mediator received: %+v", mediatorsReceived)
	log.Debugf("Execute as parent: %+v", stage)
	log.Debugf("Execute as parent name %+v", stage.GetStageName())

	mediator := stages.Mediator{States: make(map[string]string)}
	mediator.States[stage.GetStageName()] = e.executeStage(stage, mediatorsReceived, mediator)

	log.Debugf("Sending output of stage: %+v %v", stage.GetStageName(), mediator)
	*stage.GetOutputCh() <- mediator
	close(*stage.GetOutputCh())
	log.Debugf("Closed output of stage: %+v", stage.GetStageName())

	e.finalizeMonitorChAfterExecute(mediatorsReceived, mediator)
}