MCPcopy Index your code
hub / github.com/coder/coder / AllowRefresh

Method AllowRefresh

coderd/entitlements/entitlements.go:91–101  ·  view source on GitHub ↗

AllowRefresh returns whether the entitlements are allowed to be refreshed. If it returns false, that means it was recently refreshed and the caller should wait the returned duration before trying again.

(now time.Time)

Source from the content-addressed store, hash-verified

89// If it returns false, that means it was recently refreshed and the caller should
90// wait the returned duration before trying again.
91func (l *Set) AllowRefresh(now time.Time) (bool, time.Duration) {
92 l.entitlementsMu.RLock()
93 defer l.entitlementsMu.RUnlock()
94
95 diff := now.Sub(l.entitlements.RefreshedAt)
96 if diff < time.Minute {
97 return false, time.Minute - diff
98 }
99
100 return true, 0
101}
102
103func (l *Set) Feature(name codersdk.FeatureName) (codersdk.Feature, bool) {
104 l.entitlementsMu.RLock()

Callers 2

TestAllowRefreshFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestAllowRefreshFunction · 0.64