forked from mirror/redis
Cleanup context implementation
This commit is contained in:
parent
0e33c36bd1
commit
c2fb5132c0
|
@ -592,6 +592,11 @@ func NewClusterClient(opt *ClusterOptions) *ClusterClient {
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *ClusterClient) copy() *ClusterClient {
|
||||||
|
cp := *c
|
||||||
|
return &cp
|
||||||
|
}
|
||||||
|
|
||||||
// Options returns read-only Options that were used to create the client.
|
// Options returns read-only Options that were used to create the client.
|
||||||
func (c *ClusterClient) Options() *ClusterOptions {
|
func (c *ClusterClient) Options() *ClusterOptions {
|
||||||
return c.opt
|
return c.opt
|
||||||
|
|
12
redis.go
12
redis.go
|
@ -24,16 +24,14 @@ func SetLogger(logger *log.Logger) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type baseClient struct {
|
type baseClient struct {
|
||||||
connPool pool.Pooler
|
|
||||||
opt *Options
|
opt *Options
|
||||||
|
connPool pool.Pooler
|
||||||
|
|
||||||
process func(Cmder) error
|
process func(Cmder) error
|
||||||
processPipeline func([]Cmder) error
|
processPipeline func([]Cmder) error
|
||||||
processTxPipeline func([]Cmder) error
|
processTxPipeline func([]Cmder) error
|
||||||
|
|
||||||
onClose func() error // hook called when client is closed
|
onClose func() error // hook called when client is closed
|
||||||
|
|
||||||
ctx context.Context
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *baseClient) init() {
|
func (c *baseClient) init() {
|
||||||
|
@ -349,6 +347,8 @@ func (c *baseClient) txPipelineReadQueued(cn *pool.Conn, cmds []Cmder) error {
|
||||||
type Client struct {
|
type Client struct {
|
||||||
baseClient
|
baseClient
|
||||||
cmdable
|
cmdable
|
||||||
|
|
||||||
|
ctx context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
func newClient(opt *Options, pool pool.Pooler) *Client {
|
func newClient(opt *Options, pool pool.Pooler) *Client {
|
||||||
|
@ -386,10 +386,8 @@ func (c *Client) WithContext(ctx context.Context) *Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) copy() *Client {
|
func (c *Client) copy() *Client {
|
||||||
c2 := new(Client)
|
cp := *c
|
||||||
*c2 = *c
|
return &cp
|
||||||
c2.cmdable.setProcessor(c2.Process)
|
|
||||||
return c2
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Options returns read-only Options that were used to create the client.
|
// Options returns read-only Options that were used to create the client.
|
||||||
|
|
Loading…
Reference in New Issue