本文整理汇总了Golang中k8s/io/kubernetes/pkg/client/cache.DeltaCompressorFunc函数的典型用法代码示例。如果您正苦于以下问题:Golang DeltaCompressorFunc函数的具体用法?Golang DeltaCompressorFunc怎么用?Golang DeltaCompressorFunc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DeltaCompressorFunc函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewEventQueueForStore
func NewEventQueueForStore(keyFunc cache.KeyFunc, knownObjects cache.KeyListerGetter) *EventQueue {
return &EventQueue{
DeltaFIFO: cache.NewDeltaFIFO(
keyFunc,
cache.DeltaCompressorFunc(func(d cache.Deltas) cache.Deltas {
return deltaCompressor(d, keyFunc)
}),
knownObjects),
}
}
示例2: NewEventQueue
func NewEventQueue(keyFunc cache.KeyFunc) *EventQueue {
knownObjects := cache.NewStore(keyFunc)
return &EventQueue{
DeltaFIFO: cache.NewDeltaFIFO(
keyFunc,
cache.DeltaCompressorFunc(func(d cache.Deltas) cache.Deltas {
return deltaCompressor(d, keyFunc)
}),
knownObjects),
knownObjects: knownObjects,
}
}
示例3: Run
// Run starts a background goroutine that watches for changes to services that
// have (or had) LoadBalancers=true and ensures that they have
// load balancers created and deleted appropriately.
// serviceSyncPeriod controls how often we check the cluster's services to
// ensure that the correct load balancers exist.
// nodeSyncPeriod controls how often we check the cluster's nodes to determine
// if load balancers need to be updated to point to a new set.
//
// It's an error to call Run() more than once for a given ServiceController
// object.
func (s *ServiceController) Run(serviceSyncPeriod, nodeSyncPeriod time.Duration) error {
if err := s.init(); err != nil {
return err
}
// We have to make this check because the ListWatch that we use in
// WatchServices requires Client functions that aren't in the interface
// for some reason.
if _, ok := s.kubeClient.(*clientset.Clientset); !ok {
return fmt.Errorf("ServiceController only works with real Client objects, but was passed something else satisfying the clientset.Interface.")
}
// Get the currently existing set of services and then all future creates
// and updates of services.
// A delta compressor is needed for the DeltaFIFO queue because we only ever
// care about the most recent state.
serviceQueue := cache.NewDeltaFIFO(
cache.MetaNamespaceKeyFunc,
cache.DeltaCompressorFunc(func(d cache.Deltas) cache.Deltas {
if len(d) == 0 {
return d
}
return cache.Deltas{*d.Newest()}
}),
s.cache,
)
lw := cache.NewListWatchFromClient(s.kubeClient.(*clientset.Clientset).CoreClient, "services", api.NamespaceAll, fields.Everything())
cache.NewReflector(lw, &api.Service{}, serviceQueue, serviceSyncPeriod).Run()
for i := 0; i < workerGoroutines; i++ {
go s.watchServices(serviceQueue)
}
nodeLW := cache.NewListWatchFromClient(s.kubeClient.(*clientset.Clientset).CoreClient, "nodes", api.NamespaceAll, fields.Everything())
cache.NewReflector(nodeLW, &api.Node{}, s.nodeLister.Store, 0).Run()
go s.nodeSyncLoop(nodeSyncPeriod)
return nil
}