(ctx context.Context)
| 153 | } |
| 154 | |
| 155 | func (p *StickyConnPool) Reset(ctx context.Context) error { |
| 156 | if p.badConnError() == nil { |
| 157 | return nil |
| 158 | } |
| 159 | |
| 160 | select { |
| 161 | case cn, ok := <-p.ch: |
| 162 | if !ok { |
| 163 | return ErrClosed |
| 164 | } |
| 165 | p.pool.Remove(ctx, cn, ErrClosed) |
| 166 | p._badConnError.Store(BadConnError{wrapped: nil}) |
| 167 | default: |
| 168 | return errors.New("redis: StickyConnPool does not have a Conn") |
| 169 | } |
| 170 | |
| 171 | if !atomic.CompareAndSwapUint32(&p.state, stateInited, stateDefault) { |
| 172 | state := atomic.LoadUint32(&p.state) |
| 173 | return fmt.Errorf("redis: invalid StickyConnPool state: %d", state) |
| 174 | } |
| 175 | |
| 176 | return nil |
| 177 | } |
| 178 | |
| 179 | func (p *StickyConnPool) badConnError() error { |
| 180 | if v := p._badConnError.Load(); v != nil { |
no test coverage detected