From 81755c860a637196b5bf13eb7030ae3aedc8d6d2 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Mon, 13 Apr 2020 15:57:19 -0400 Subject: [PATCH] agent/cache: remove error return from fetch A previous change removed the only error, so the return value can be removed now. --- agent/cache/cache.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/agent/cache/cache.go b/agent/cache/cache.go index 602233562a..6f9aec9126 100644 --- a/agent/cache/cache.go +++ b/agent/cache/cache.go @@ -388,10 +388,7 @@ RETRY_GET: // At this point, we know we either don't have a value at all or the // value we have is too old. We need to wait for new data. - waiterCh, err := c.fetch(key, r, true, 0, false) - if err != nil { - return nil, ResultMeta{Index: entry.Index}, err - } + waiterCh := c.fetch(key, r, true, 0, false) // No longer our first time through first = false @@ -420,20 +417,18 @@ func makeEntryKey(t, dc, token, key string) string { // If allowNew is true then the fetch should create the cache entry // if it doesn't exist. If this is false, then fetch will do nothing // if the entry doesn't exist. This latter case is to support refreshing. -func (c *Cache) fetch(key string, r getOptions, allowNew bool, attempt uint, ignoreExisting bool) (<-chan struct{}, error) { - info := r.Info - +func (c *Cache) fetch(key string, r getOptions, allowNew bool, attempt uint, ignoreExisting bool) <-chan struct{} { // We acquire a write lock because we may have to set Fetching to true. c.entriesLock.Lock() defer c.entriesLock.Unlock() - ok, entryValid, entry := c.getEntryLocked(r.TypeEntry, key, info) + ok, entryValid, entry := c.getEntryLocked(r.TypeEntry, key, r.Info) // This handles the case where a fetch succeeded after checking for its existence in // getWithIndex. This ensures that we don't miss updates. if ok && entryValid && !ignoreExisting { ch := make(chan struct{}) close(ch) - return ch, nil + return ch } // If we aren't allowing new values and we don't have an existing value, @@ -442,13 +437,13 @@ func (c *Cache) fetch(key string, r getOptions, allowNew bool, attempt uint, ign if !ok && !allowNew { ch := make(chan struct{}) close(ch) - return ch, nil + return ch } // If we already have an entry and it is actively fetching, then return // the currently active waiter. if ok && entry.Fetching { - return entry.Waiter, nil + return entry.Waiter } // If we don't have an entry, then create it. The entry must be marked @@ -645,7 +640,7 @@ func (c *Cache) fetch(key string, r getOptions, allowNew bool, attempt uint, ign } }() - return entry.Waiter, nil + return entry.Waiter } func backOffWait(failures uint) time.Duration {