本文整理汇总了Golang中k8s/io/kubernetes/pkg/client/cache.Reflector类的典型用法代码示例。如果您正苦于以下问题:Golang Reflector类的具体用法?Golang Reflector怎么用?Golang Reflector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Reflector类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: runReflectorUntil
// runReflectorUntil is equivalent to cache.Reflector.RunUntil, but it also logs
// errors, which cache.Reflector.RunUntil simply ignores
func runReflectorUntil(r *cache.Reflector, resyncPeriod time.Duration, stopCh <-chan struct{}) {
loggingListAndWatch := func() {
if err := r.ListAndWatch(stopCh); err != nil {
log.Errorf("Kubernetes reflector: %v", err)
}
}
go util.Until(loggingListAndWatch, resyncPeriod, stopCh)
}
示例2: sendWatchReadiness
// Ensures given event queue is ready for watching new changes
// and unblock other end of the ready channel
func sendWatchReadiness(reflector *cache.Reflector, ready chan<- bool) {
// timeout: 1min
retries := 120
retryInterval := 500 * time.Millisecond
// Try every retryInterval and bail-out if it exceeds max retries
for i := 0; i < retries; i++ {
// Reflector does list and watch of the resource
// when listing of the resource is done, resourceVersion will be populated
// and the event queue will be ready to watch any new changes
version := reflector.LastSyncResourceVersion()
if len(version) > 0 {
ready <- true
return
}
time.Sleep(retryInterval)
}
log.Fatalf("SDN event queue is not ready for watching new changes(timeout: 1min)")
}