(ctx context.Context)
| 400 | } |
| 401 | |
| 402 | func (c *baseClient) _getConn(ctx context.Context) (*pool.Conn, error) { |
| 403 | cn, err := c.connPool.Get(ctx) |
| 404 | if err != nil { |
| 405 | return nil, err |
| 406 | } |
| 407 | |
| 408 | if cn.IsInited() { |
| 409 | return cn, nil |
| 410 | } |
| 411 | |
| 412 | if err := c.initConn(ctx, cn); err != nil { |
| 413 | c.connPool.Remove(ctx, cn, err) |
| 414 | if err := errors.Unwrap(err); err != nil { |
| 415 | return nil, err |
| 416 | } |
| 417 | return nil, err |
| 418 | } |
| 419 | |
| 420 | if dialStartNs := cn.GetDialStartNs(); dialStartNs > 0 { |
| 421 | if cb := pool.GetMetricConnectionCreateTimeCallback(); cb != nil { |
| 422 | duration := time.Duration(time.Now().UnixNano() - dialStartNs) |
| 423 | cb(ctx, duration, cn) |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | // initConn will transition to IDLE state, so we need to acquire it |
| 428 | // before returning it to the user. |
| 429 | if !cn.TryAcquire() { |
| 430 | return nil, fmt.Errorf("redis: connection is not usable") |
| 431 | } |
| 432 | |
| 433 | return cn, nil |
| 434 | } |
| 435 | |
| 436 | func (c *baseClient) reAuthConnection() func(poolCn *pool.Conn, credentials auth.Credentials) error { |
| 437 | return func(poolCn *pool.Conn, credentials auth.Credentials) error { |
no test coverage detected