1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

feat: add ContextTimeoutEnabled to respect context timeouts and deadlines

This commit is contained in:
Vladimir Mihailenco
2022-10-11 10:22:42 +03:00
parent 8319b1ebf0
commit 58f7149e38
8 changed files with 92 additions and 59 deletions

View File

@ -63,7 +63,9 @@ func (cn *Conn) RemoteAddr() net.Addr {
return nil
}
func (cn *Conn) WithReader(ctx context.Context, timeout time.Duration, fn func(rd *proto.Reader) error) error {
func (cn *Conn) WithReader(
ctx context.Context, timeout time.Duration, fn func(rd *proto.Reader) error,
) error {
if timeout >= 0 {
if err := cn.netConn.SetReadDeadline(cn.deadline(ctx, timeout)); err != nil {
return err