本文整理汇总了Golang中github.com/vmware/vic/pkg/trace.Operation.Done方法的典型用法代码示例。如果您正苦于以下问题:Golang Operation.Done方法的具体用法?Golang Operation.Done怎么用?Golang Operation.Done使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/vmware/vic/pkg/trace.Operation
的用法示例。
在下文中一共展示了Operation.Done方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: waitForPath
func waitForPath(op trace.Operation, path string) error {
defer trace.End(trace.Begin(path))
timeout := time.Duration(pathTimeout)
op, _ = trace.WithTimeout(&op, timeout, path)
done := make(chan struct{})
go func() {
t := time.NewTicker(200 * time.Microsecond)
defer t.Stop()
for range t.C {
if _, err := os.Stat(path); err == nil {
close(done)
break
}
// We've timed out.
if op.Err() != nil {
break
}
}
}()
log.Debugf("Waiting for attached disk to appear in /dev/disk/by-path, or timeout")
select {
case <-done:
log.Infof("Attached disk present at %s", path)
case <-op.Done():
if op.Err() != nil {
return errors.Errorf("timeout waiting for layer to present as %s", path)
}
}
return nil
}