89
}
90
91
>
func (m *managerImpl) needRefreshCache(saCache cache, forceRefreshCache bool, now time.Time) bool {
manager.go
92
>
return forceRefreshCache || saCache.expireOn.Before(now) || m.forceRefresh()
93
>
}
94
95
>
func (m *managerImpl) refreshCache(forceRefreshCache bool, now time.Time) (cache, error) {
manager.go
96
>
//nolint:revive // cache value is always of type `cache`
97
>
saCache := m.cache.Load().(cache)
98
>
if !m.needRefreshCache(saCache, forceRefreshCache, now) {
99
return saCache, nil
100
}
101
103
>
defer m.cacheUpdateMutex.Unlock()
104
>
//nolint:revive // cache value is always of type `cache`
105
>
saCache = m.cache.Load().(cache)
106
>
if !m.needRefreshCache(saCache, forceRefreshCache, now) {
107
return saCache, nil
108
}
109
110
>
return m.refreshCacheLocked(saCache, now)
manager.go
111
}
112
113
>
func (m *managerImpl) refreshCacheLocked(saCache cache, now time.Time) (cache, error) {
manager.go
114
>
ctx, cancel := context.WithTimeout(context.Background(), cacheRefreshTimeout)
115
>
defer cancel()
116
>
if saCache.dbVersion == 0 {
117
>
// if cache is cold, use the highest priority caller
118
>
ctx = headers.SetCallerInfo(ctx, headers.SystemOperatorCallerInfo)
119
>
} else {
120
ctx = headers.SetCallerInfo(ctx, headers.SystemBackgroundHighCallerInfo)
121
}
122
123
>
clusterMetadata, err := m.clusterMetadataManager.GetCurrentClusterMetadata(ctx)
manager.go
124
>
if err != nil {
125
switch err.(type) {
126
case *serviceerror.NotFound: