本文整理匯總了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
}