2017-01-13 07:11:07 +03:00
|
|
|
// +build go1.7
|
|
|
|
|
|
|
|
package redis
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2017-02-18 17:42:34 +03:00
|
|
|
"github.com/go-redis/redis/internal/pool"
|
2017-01-13 07:11:07 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
type baseClient struct {
|
|
|
|
connPool pool.Pooler
|
|
|
|
opt *Options
|
|
|
|
|
2018-01-20 13:26:33 +03:00
|
|
|
process func(Cmder) error
|
|
|
|
processPipeline func([]Cmder) error
|
|
|
|
processTxPipeline func([]Cmder) error
|
|
|
|
|
2017-01-13 07:11:07 +03:00
|
|
|
onClose func() error // hook called when client is closed
|
|
|
|
|
|
|
|
ctx context.Context
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Client) Context() context.Context {
|
|
|
|
if c.ctx != nil {
|
|
|
|
return c.ctx
|
|
|
|
}
|
|
|
|
return context.Background()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Client) WithContext(ctx context.Context) *Client {
|
|
|
|
if ctx == nil {
|
|
|
|
panic("nil context")
|
|
|
|
}
|
|
|
|
c2 := c.copy()
|
|
|
|
c2.ctx = ctx
|
|
|
|
return c2
|
|
|
|
}
|