mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 07:57:35 +00:00
Support namespacing in cache.Store implementations
Support namespacing in cache.Store by framing the interface functions
around interface{} and providing a key function to each Store implementation.
Implementation of a fix for #2294.
This commit is contained in:
15
pkg/client/cache/poller.go
vendored
15
pkg/client/cache/poller.go
vendored
@@ -27,7 +27,7 @@ import (
|
||||
// one object at a time.
|
||||
type Enumerator interface {
|
||||
Len() int
|
||||
Get(index int) (ID string, object interface{})
|
||||
Get(index int) (object interface{})
|
||||
}
|
||||
|
||||
// GetFunc should return an enumerator that you wish the Poller to proccess.
|
||||
@@ -76,14 +76,11 @@ func (p *Poller) run() {
|
||||
}
|
||||
|
||||
func (p *Poller) sync(e Enumerator) {
|
||||
current := p.store.ContainedIDs()
|
||||
items := []interface{}{}
|
||||
for i := 0; i < e.Len(); i++ {
|
||||
id, object := e.Get(i)
|
||||
p.store.Update(id, object)
|
||||
current.Delete(id)
|
||||
}
|
||||
// Delete all the objects not found.
|
||||
for id := range current {
|
||||
p.store.Delete(id)
|
||||
object := e.Get(i)
|
||||
items = append(items, object)
|
||||
}
|
||||
|
||||
p.store.Replace(items)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user