Debian Codegraph @

redis_context.go

raw
1 // +build go1.7
2
3 package redis
4
5 import (
6 "context"
7
8 "gopkg.in/redis.v5/internal/pool"
9 )
10
11 type baseClient struct {
12 connPool pool.Pooler
13 opt *Options
14
15 process func(Cmder) error
16 onClose func() error // hook called when client is closed
17
18 ctx context.Context
19 }
20
21 func (c *Client) Context() context.Context {
22 if c.ctx != nil {
23 return c.ctx
24 }
25 return context.Background()
26 }
27
28 func (c *Client) WithContext(ctx context.Context) *Client {
29 if ctx == nil {
30 panic("nil context")
31 }
32 c2 := c.copy()
33 c2.ctx = ctx
34 return c2
35 }