State returns the current state of the key, derived from its permanent flag and cooldown deadline.
()
| 126 | // State returns the current state of the key, derived from its |
| 127 | // permanent flag and cooldown deadline. |
| 128 | func (k *Key) State() KeyState { |
| 129 | k.mu.RLock() |
| 130 | defer k.mu.RUnlock() |
| 131 | |
| 132 | if k.permanent { |
| 133 | return KeyStatePermanent |
| 134 | } |
| 135 | // Cooldown still active: key is temporarily unavailable. |
| 136 | if k.clock.Now().Before(k.cooldownUntil) { |
| 137 | return KeyStateTemporary |
| 138 | } |
| 139 | return KeyStateValid |
| 140 | } |
| 141 | |
| 142 | // stateAndCooldown returns the key's state and remaining |
| 143 | // cooldown as a single atomic snapshot. |
no outgoing calls