agent/cache: Small formatting improvements to improve readability

Remove Cache.entryKey which called a single function.
Format multiline struct creation one field per line.
This commit is contained in:
Daniel Nephin 2020-04-02 14:35:58 -04:00
parent 329d76fd0e
commit e9e45545dd
1 changed files with 9 additions and 12 deletions

21
agent/cache/cache.go vendored
View File

@ -610,15 +610,8 @@ func (c *Cache) fetch(tEntry typeEntry, key string, r Request, allowNew bool, at
// in multiple actual RPC calls (unlike fetch).
func (c *Cache) fetchDirect(tEntry typeEntry, r Request, minIndex uint64) (interface{}, ResultMeta, error) {
// Fetch it with the min index specified directly by the request.
result, err := tEntry.Type.Fetch(FetchOptions{
MinIndex: minIndex,
}, r)
if err != nil {
return nil, ResultMeta{}, err
}
// Return the result and ignore the rest
return result.Value, ResultMeta{}, nil
result, err := tEntry.Type.Fetch(FetchOptions{MinIndex: minIndex}, r)
return result.Value, ResultMeta{}, err
}
func backOffWait(failures uint) time.Duration {
@ -742,9 +735,13 @@ func (c *Cache) Prepopulate(t string, res FetchResult, dc, token, k string) erro
}
key := makeEntryKey(t, dc, token, k)
newEntry := cacheEntry{
Valid: true, Value: res.Value, State: res.State, Index: res.Index,
FetchedAt: time.Now(), Waiter: make(chan struct{}),
Expiry: &cacheEntryExpiry{Key: key, TTL: tEntry.Opts.LastGetTTL},
Valid: true,
Value: res.Value,
State: res.State,
Index: res.Index,
FetchedAt: time.Now(),
Waiter: make(chan struct{}),
Expiry: &cacheEntryExpiry{Key: key, TTL: tEntry.Opts.LastGetTTL},
}
c.entriesLock.Lock()
c.entries[key] = newEntry