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)
| 89 | // If it returns false, that means it was recently refreshed and the caller should |
| 90 | // wait the returned duration before trying again. |
| 91 | func (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 | |
| 103 | func (l *Set) Feature(name codersdk.FeatureName) (codersdk.Feature, bool) { |
| 104 | l.entitlementsMu.RLock() |
no outgoing calls