Add fast-path for Listing with ResourceVersion=0

This commit is contained in:
gmarek 2016-11-18 13:54:10 +01:00
parent 3932d127e5
commit e1542300ae

View File

@ -283,10 +283,13 @@ func (w *watchCache) waitUntilFreshAndBlock(resourceVersion uint64, trace *util.
// WaitUntilFreshAndList returns list of pointers to <storeElement> objects. // WaitUntilFreshAndList returns list of pointers to <storeElement> objects.
func (w *watchCache) WaitUntilFreshAndList(resourceVersion uint64, trace *util.Trace) ([]interface{}, uint64, error) { func (w *watchCache) WaitUntilFreshAndList(resourceVersion uint64, trace *util.Trace) ([]interface{}, uint64, error) {
err := w.waitUntilFreshAndBlock(resourceVersion, trace) // If resourceVersion == 0 we'll return the data that we currently have in cache.
defer w.RUnlock() if resourceVersion != 0 {
if err != nil { err := w.waitUntilFreshAndBlock(resourceVersion, trace)
return nil, 0, err defer w.RUnlock()
if err != nil {
return nil, 0, err
}
} }
return w.store.List(), w.resourceVersion, nil return w.store.List(), w.resourceVersion, nil
} }