mirror of
https://github.com/go-gitea/gitea.git
synced 2024-08-25 21:57:29 +02:00
* Update go-redis to v8.4.0 * github.com/go-redis/redis/v8 v8.4.0 -> v8.5.0 * Apply suggestions from code review Co-authored-by: zeripath <art27@cantab.net> * TODO * Use the Queue termination channel as the default context for pushes Signed-off-by: Andrew Thornton <art27@cantab.net> * missed one Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: zeripath <art27@cantab.net>
59 lines
1.0 KiB
Go
Vendored
59 lines
1.0 KiB
Go
Vendored
package pool
|
|
|
|
import "context"
|
|
|
|
type SingleConnPool struct {
|
|
pool Pooler
|
|
cn *Conn
|
|
stickyErr error
|
|
}
|
|
|
|
var _ Pooler = (*SingleConnPool)(nil)
|
|
|
|
func NewSingleConnPool(pool Pooler, cn *Conn) *SingleConnPool {
|
|
return &SingleConnPool{
|
|
pool: pool,
|
|
cn: cn,
|
|
}
|
|
}
|
|
|
|
func (p *SingleConnPool) NewConn(ctx context.Context) (*Conn, error) {
|
|
return p.pool.NewConn(ctx)
|
|
}
|
|
|
|
func (p *SingleConnPool) CloseConn(cn *Conn) error {
|
|
return p.pool.CloseConn(cn)
|
|
}
|
|
|
|
func (p *SingleConnPool) Get(ctx context.Context) (*Conn, error) {
|
|
if p.stickyErr != nil {
|
|
return nil, p.stickyErr
|
|
}
|
|
return p.cn, nil
|
|
}
|
|
|
|
func (p *SingleConnPool) Put(ctx context.Context, cn *Conn) {}
|
|
|
|
func (p *SingleConnPool) Remove(ctx context.Context, cn *Conn, reason error) {
|
|
p.cn = nil
|
|
p.stickyErr = reason
|
|
}
|
|
|
|
func (p *SingleConnPool) Close() error {
|
|
p.cn = nil
|
|
p.stickyErr = ErrClosed
|
|
return nil
|
|
}
|
|
|
|
func (p *SingleConnPool) Len() int {
|
|
return 0
|
|
}
|
|
|
|
func (p *SingleConnPool) IdleLen() int {
|
|
return 0
|
|
}
|
|
|
|
func (p *SingleConnPool) Stats() *Stats {
|
|
return &Stats{}
|
|
}
|