forked from redis/go-redis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
51 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// +build go1.7 | ||
|
||
package redis | ||
|
||
import ( | ||
"context" | ||
|
||
"gopkg.in/redis.v5/internal/pool" | ||
) | ||
|
||
type baseClient struct { | ||
connPool pool.Pooler | ||
opt *Options | ||
|
||
process func(Cmder) error | ||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// +build !go1.7 | ||
|
||
package redis | ||
|
||
import ( | ||
"gopkg.in/redis.v5/internal/pool" | ||
) | ||
|
||
type baseClient struct { | ||
connPool pool.Pooler | ||
opt *Options | ||
|
||
process func(Cmder) error | ||
onClose func() error // hook called when client is closed | ||
} |