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

Method stateAndCooldown

aibridge/keypool/keypool.go:144–156  ·  view source on GitHub ↗

stateAndCooldown returns the key's state and remaining cooldown as a single atomic snapshot.

()

Source from the content-addressed store, hash-verified

142// stateAndCooldown returns the key's state and remaining
143// cooldown as a single atomic snapshot.
144func (k *Key) stateAndCooldown() (KeyState, time.Duration) {
145 k.mu.RLock()
146 defer k.mu.RUnlock()
147
148 if k.permanent {
149 return KeyStatePermanent, 0
150 }
151 now := k.clock.Now()
152 if now.Before(k.cooldownUntil) {
153 return KeyStateTemporary, k.cooldownUntil.Sub(now)
154 }
155 return KeyStateValid, 0
156}
157
158// MarkTemporary marks the key as temporarily unavailable with
159// the specified cooldown duration. Returns true if this call

Callers 1

keyPoolErrorMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected