mirror of https://github.com/hashicorp/consul
agent/cache: Small formatting improvements to improve readability
Remove Cache.entryKey which called a single function. Format multiline struct creation one field per line.pull/7585/head
parent
329d76fd0e
commit
e9e45545dd
|
@ -610,15 +610,8 @@ func (c *Cache) fetch(tEntry typeEntry, key string, r Request, allowNew bool, at
|
||||||
// in multiple actual RPC calls (unlike fetch).
|
// in multiple actual RPC calls (unlike fetch).
|
||||||
func (c *Cache) fetchDirect(tEntry typeEntry, r Request, minIndex uint64) (interface{}, ResultMeta, error) {
|
func (c *Cache) fetchDirect(tEntry typeEntry, r Request, minIndex uint64) (interface{}, ResultMeta, error) {
|
||||||
// Fetch it with the min index specified directly by the request.
|
// Fetch it with the min index specified directly by the request.
|
||||||
result, err := tEntry.Type.Fetch(FetchOptions{
|
result, err := tEntry.Type.Fetch(FetchOptions{MinIndex: minIndex}, r)
|
||||||
MinIndex: minIndex,
|
return result.Value, ResultMeta{}, err
|
||||||
}, r)
|
|
||||||
if err != nil {
|
|
||||||
return nil, ResultMeta{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the result and ignore the rest
|
|
||||||
return result.Value, ResultMeta{}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func backOffWait(failures uint) time.Duration {
|
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)
|
key := makeEntryKey(t, dc, token, k)
|
||||||
newEntry := cacheEntry{
|
newEntry := cacheEntry{
|
||||||
Valid: true, Value: res.Value, State: res.State, Index: res.Index,
|
Valid: true,
|
||||||
FetchedAt: time.Now(), Waiter: make(chan struct{}),
|
Value: res.Value,
|
||||||
Expiry: &cacheEntryExpiry{Key: key, TTL: tEntry.Opts.LastGetTTL},
|
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.entriesLock.Lock()
|
||||||
c.entries[key] = newEntry
|
c.entries[key] = newEntry
|
||||||
|
|
Loading…
Reference in New Issue