本文整理汇总了Golang中github.com/recruit-tech/walter/stages.Stage类的典型用法代码示例。如果您正苦于以下问题:Golang Stage类的具体用法?Golang Stage怎么用?Golang Stage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Stage类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Execute
//Execute executes a stage using the supplied mediator
func (e *Engine) Execute(stage stages.Stage, mediator stages.Mediator) stages.Mediator {
monitorCh := e.MonitorCh
mediator.Type = "start"
name := stage.GetStageName()
log.Debugf("----- Execute %v start ------\n", name)
go func(mediator stages.Mediator) {
*stage.GetInputCh() <- mediator
close(*stage.GetInputCh())
}(mediator)
go e.ExecuteStage(stage)
for {
receive, ok := <-*stage.GetOutputCh()
if !ok {
log.Debugf("outputCh closed")
break
}
log.Debugf("outputCh received %+v\n", receive)
}
var receives = make([]stages.Mediator, 0)
for {
receive := <-*monitorCh
receives = append(receives, receive)
if receive.Type == "end" {
log.Debugf("monitorCh closed")
log.Debugf("monitorCh last received: %+v\n", receive)
log.Debugf("----- Execute %v done ------\n\n", name)
return e.bindReceives(&receives)
}
log.Debugf("monitorCh received %+v\n", receive)
}
}
开发者ID:hotchemi,项目名称:walter,代码行数:36,代码来源:engine.go
示例2: execute
func execute(stage stages.Stage) stages.Mediator {
mon := make(chan stages.Mediator)
e := &Engine{
MonitorCh: &mon,
Resources: &pipelines.Resources{
Reporter: &messengers.FakeMessenger{},
},
}
go e.ExecuteStage(stage)
mediator := stages.Mediator{States: make(map[string]string), Type: "start"}
go func() {
*stage.GetInputCh() <- mediator
close(*stage.GetInputCh())
}()
for {
_, ok := <-*stage.GetOutputCh()
if !ok {
break
}
}
var m stages.Mediator
acm := stages.Mediator{States: make(map[string]string)}
for {
m = <-mon
for k, v := range m.States {
acm.States[k] = v
}
if m.Type == "end" {
break
}
}
return acm
}
开发者ID:jacec,项目名称:walter,代码行数:37,代码来源:engine_test.go
示例3: ReportStageResult
// ReportStageResult throw the results of specified stage to the messenger services.
func (self *Resources) ReportStageResult(stage stages.Stage, resultStr string) {
name := stage.GetStageName()
if !self.Reporter.Suppress("result") {
if resultStr == "true" {
self.Reporter.Post(
fmt.Sprintf("[%s][RESULT] Succeeded", name))
} else if resultStr == "skipped" {
self.Reporter.Post(
fmt.Sprintf("[%s][RESULT] Skipped", name))
} else {
self.Reporter.Post(
fmt.Sprintf("[%s][RESULT] Failed", name))
}
}
if stage.GetStageOpts().ReportingFullOutput {
if out := stage.GetOutResult(); (len(out) > 0) && (!self.Reporter.Suppress("stdout")) {
self.Reporter.Post(
fmt.Sprintf("[%s][STDOUT] %s", name, stage.GetOutResult()))
}
if err := stage.GetErrResult(); len(err) > 0 && (!self.Reporter.Suppress("stderr")) {
self.Reporter.Post(
fmt.Sprintf("[%s][STDERR] %s", name, stage.GetErrResult()))
}
}
}
开发者ID:jacec,项目名称:walter,代码行数:27,代码来源:pipeline.go
示例4: ExecuteStage
// 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())
var result string
if !e.isUpstreamAnyFailure(mediatorsReceived) || e.Opts.StopOnAnyFailure {
result = strconv.FormatBool(stage.(stages.Runner).Run())
} else {
log.Warnf("Execution is skipped: %v", stage.GetStageName())
result = "skipped"
}
log.Debugf("Stage execution results: %+v, %+v", stage.GetStageName(), result)
e.Resources.ReportStageResult(stage, result)
mediator := stages.Mediator{States: make(map[string]string)}
mediator.States[stage.GetStageName()] = result
if childStages := stage.GetChildStages(); childStages.Len() > 0 {
log.Debugf("Execute childstage: %v", childStages)
e.executeAllChildStages(&childStages, mediator)
e.waitAllChildStages(&childStages, &stage)
}
log.Debugf("Sending output of stage: %+v %v", stage.GetStageName(), mediator)
*stage.GetOutputCh() <- mediator
log.Debugf("Closing output of stage: %+v", stage.GetStageName())
close(*stage.GetOutputCh())
for _, m := range mediatorsReceived {
*e.MonitorCh <- m
}
*e.MonitorCh <- mediator
e.finalizeMonitorChAfterExecute(mediatorsReceived)
}
开发者ID:hotchemi,项目名称:walter,代码行数:42,代码来源:engine.go
注:本文中的github.com/recruit-tech/walter/stages.Stage类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论