本文整理汇总了Golang中github.com/pquerna/hurl/common.UI.WorkStart方法的典型用法代码示例。如果您正苦于以下问题:Golang UI.WorkStart方法的具体用法?Golang UI.WorkStart怎么用?Golang UI.WorkStart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pquerna/hurl/common.UI
的用法示例。
在下文中一共展示了UI.WorkStart方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Run
func Run(ui common.UI, taskType string) error {
// if clusterConf != "" {
// // TODO: add ClusterWorker
// return nil, fmt.Errorf("TODO: Cluster support")
// }
wt, ok := g_workers_tasks[taskType]
if !ok {
return fmt.Errorf("unknown worker type: %s", taskType)
}
conf := ui.ConfigGet()
bconf := conf.GetBasicConfig()
workers := make([]Worker, bconf.Concurrency)
for index, _ := range workers {
w, err := wt(ui)
if err != nil {
return err
}
workers[index] = &LocalWorker{task: w}
}
ui.WorkStart(bconf.NumRequests)
defer func() {
for _, worker := range workers {
worker.Halt()
}
}()
var wg sync.WaitGroup
var wgres sync.WaitGroup
reqchan := make(chan int64, 1024*1024)
// TODO: how big should this be?
reschan := make(chan *common.Result)
for _, worker := range workers {
err := worker.Start(taskType, &wg, reqchan, reschan)
if err != nil {
return err
}
}
var i int64
for i = 0; i < bconf.NumRequests; i++ {
reqchan <- i
// TOOD: ui.WorkStatus(numDone int64)
}
wgres.Add(1)
rw := common.NewResultArchiveWriter()
defer rw.Remove()
go resultHanlder(ui, &wgres, reschan, rw)
close(reqchan)
wg.Wait()
close(reschan)
wgres.Wait()
ui.WorkEnd()
rw.Close()
rr := common.NewResultArchiveReader(rw.Path)
return reports.Run(ui, taskType, conf, rr)
}