cachedGetter caches a token until it gets expired, after the expiration, it will generate another token and cache it.
| 80 | // cachedGetter caches a token until it gets expired, after the expiration, it will |
| 81 | // generate another token and cache it. |
| 82 | type cachedGetter struct { |
| 83 | mutex sync.Mutex |
| 84 | tokenGetter TokenGetter |
| 85 | |
| 86 | token string |
| 87 | born time.Time |
| 88 | ttl time.Duration |
| 89 | } |
| 90 | |
| 91 | // Token returns the current available token, create a new one if expired. |
| 92 | func (c *cachedGetter) Token() (string, error) { |
nothing calls this directly
no outgoing calls
no test coverage detected