From 8aa3335b22be332341e646310f166aa51e6ef8bd Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Mon, 6 Jul 2020 12:59:44 -0400 Subject: [PATCH] agent/cache: Update some docstrings --- agent/cache/cache.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/agent/cache/cache.go b/agent/cache/cache.go index 9b8845b64..15e7b1a3d 100644 --- a/agent/cache/cache.go +++ b/agent/cache/cache.go @@ -167,15 +167,12 @@ type RegisterOptions struct { // client requests them with MinIndex. SupportsBlocking bool - // RefreshTimer is the time between attempting to refresh data. + // RefreshTimer is the time to sleep between attempts to refresh data. // If this is zero, then data is refreshed immediately when a fetch // is returned. // - // RefreshTimeout determines the maximum query time for a refresh - // operation. This is specified as part of the query options and is - // expected to be implemented by the Type itself. - // - // Using these values, various "refresh" mechanisms can be implemented: + // Using different values for RefreshTimer and RefreshTimeout, various + // "refresh" mechanisms can be implemented: // // * With a high timer duration and a low timeout, a timer-based // refresh can be set that minimizes load on the Consul servers. @@ -184,7 +181,11 @@ type RegisterOptions struct { // refresh can be set so that changes in server data are recognized // within the cache very quickly. // - RefreshTimer time.Duration + RefreshTimer time.Duration + + // RefreshTimeout is the default value for the maximum query time for a fetch + // operation. It is set as FetchOptions.Timeout so that cache.Type + // implementations can use it as the MaxQueryTime. RefreshTimeout time.Duration } @@ -473,8 +474,7 @@ func (c *Cache) fetch(key string, r getOptions, allowNew bool, attempt uint, ign // keepalives are every 30 seconds so the RPC should fail if the packets are // being blackholed for more than 30 seconds. var connectedTimer *time.Timer - if tEntry.Opts.Refresh && entry.Index > 0 && - tEntry.Opts.RefreshTimeout > (31*time.Second) { + if tEntry.Opts.Refresh && entry.Index > 0 && tEntry.Opts.RefreshTimeout > 31*time.Second { connectedTimer = time.AfterFunc(31*time.Second, func() { c.entriesLock.Lock() defer c.entriesLock.Unlock()