MCPcopy
hub / github.com/redis/go-redis / Reset

Method Reset

internal/pool/pool_sticky.go:155–177  ·  internal/pool/pool_sticky.go::StickyConnPool.Reset
(ctx context.Context)

Source from the content-addressed store, hash-verified

153}
154
155func (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
179func (p *StickyConnPool) badConnError() error {
180 if v := p._badConnError.Load(); v != nil {

Callers 2

SetNetConnMethod · 0.45
WithWriterMethod · 0.45

Calls 2

badConnErrorMethod · 0.95
RemoveMethod · 0.65

Tested by

no test coverage detected