mirror of https://github.com/status-im/consul.git
agent/cache: remove error return from fetch
A previous change removed the only error, so the return value can be removed now.
This commit is contained in:
parent
4ef9fc9f27
commit
81755c860a
|
@ -388,10 +388,7 @@ RETRY_GET:
|
||||||
|
|
||||||
// At this point, we know we either don't have a value at all or the
|
// 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.
|
// value we have is too old. We need to wait for new data.
|
||||||
waiterCh, err := c.fetch(key, r, true, 0, false)
|
waiterCh := c.fetch(key, r, true, 0, false)
|
||||||
if err != nil {
|
|
||||||
return nil, ResultMeta{Index: entry.Index}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// No longer our first time through
|
// No longer our first time through
|
||||||
first = false
|
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 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 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.
|
// 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) {
|
func (c *Cache) fetch(key string, r getOptions, allowNew bool, attempt uint, ignoreExisting bool) <-chan struct{} {
|
||||||
info := r.Info
|
|
||||||
|
|
||||||
// We acquire a write lock because we may have to set Fetching to true.
|
// We acquire a write lock because we may have to set Fetching to true.
|
||||||
c.entriesLock.Lock()
|
c.entriesLock.Lock()
|
||||||
defer c.entriesLock.Unlock()
|
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
|
// This handles the case where a fetch succeeded after checking for its existence in
|
||||||
// getWithIndex. This ensures that we don't miss updates.
|
// getWithIndex. This ensures that we don't miss updates.
|
||||||
if ok && entryValid && !ignoreExisting {
|
if ok && entryValid && !ignoreExisting {
|
||||||
ch := make(chan struct{})
|
ch := make(chan struct{})
|
||||||
close(ch)
|
close(ch)
|
||||||
return ch, nil
|
return ch
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we aren't allowing new values and we don't have an existing value,
|
// 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 {
|
if !ok && !allowNew {
|
||||||
ch := make(chan struct{})
|
ch := make(chan struct{})
|
||||||
close(ch)
|
close(ch)
|
||||||
return ch, nil
|
return ch
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we already have an entry and it is actively fetching, then return
|
// If we already have an entry and it is actively fetching, then return
|
||||||
// the currently active waiter.
|
// the currently active waiter.
|
||||||
if ok && entry.Fetching {
|
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
|
// 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 {
|
func backOffWait(failures uint) time.Duration {
|
||||||
|
|
Loading…
Reference in New Issue