IsUsable returns true if the connection is safe to use for new commands (lock-free). A connection is "usable" when it's in a stable state and can be returned to clients. It becomes unusable during: - Handoff operations (network connection replacement) - Re-authentication (credential updates) - Othe
()
| 276 | // Note: CREATED state is considered usable because new connections need to pass OnGet() hook |
| 277 | // before initialization. The initialization happens after OnGet() in the client code. |
| 278 | func (cn *Conn) IsUsable() bool { |
| 279 | state := cn.stateMachine.GetState() |
| 280 | // CREATED, IDLE, and IN_USE states are considered usable |
| 281 | // CREATED: new connection, not yet initialized (will be initialized by client) |
| 282 | // IDLE: initialized and ready to be acquired |
| 283 | // IN_USE: usable but currently acquired by someone |
| 284 | return state == StateCreated || state == StateIdle || state == StateInUse |
| 285 | } |
| 286 | |
| 287 | // SetUsable sets the usable flag for the connection (lock-free). |
| 288 | // |