[GH-ISSUE #256] [FEATURE REQUEST] Specifying Dial/Read/Write Timeouts for the redis.Client #2119

Closed
opened 2026-03-15 19:15:14 +03:00 by kerem · 1 comment
Owner

Originally created by @dhh93 on GitHub (Mar 24, 2021).
Original GitHub issue: https://github.com/hibiken/asynq/issues/256

Originally assigned to: @hibiken on GitHub.

Thanks for the fantastic library & documentation, it's been great to work with.

Was wondering if we could modify the RedisClientOpt, RedisFailoverClientOpt, and RedisClusterClientOpt structs behind the RedisConnOpt to support customized Dial, Read, and Write timeouts.

Currently, the default values are passed when instantiating the *asynq.Client:

  • 5 seconds for Dial
  • 3 seconds for Read/Write

In most circumstances, the defaults have been working fine, but I have gotten some i/o timeout errors during periods when the underlying redis server is under heavy load.

Here's the current definition of the RedisClientOpt. I think adding fields for the respective timeouts should suffice.

// RedisClientOpt is used to create a redis client that connects
// to a redis server directly.
type RedisClientOpt struct {
	// Network type to use, either tcp or unix.
	// Default is tcp.
	Network string

	// Redis server address in "host:port" format.
	Addr string

	// Username to authenticate the current connection when Redis ACLs are used.
	// See: https://redis.io/commands/auth.
	Username string

	// Password to authenticate the current connection.
	// See: https://redis.io/commands/auth.
	Password string

	// Redis DB to select after connecting to a server.
	// See: https://redis.io/commands/select.
	DB int

	// Maximum number of socket connections.
	// Default is 10 connections per every CPU as reported by runtime.NumCPU.
	PoolSize int

	// TLS Config used to connect to a server.
	// TLS will be negotiated only if this field is set.
	TLSConfig *tls.Config
}
Originally created by @dhh93 on GitHub (Mar 24, 2021). Original GitHub issue: https://github.com/hibiken/asynq/issues/256 Originally assigned to: @hibiken on GitHub. Thanks for the fantastic library & documentation, it's been great to work with. Was wondering if we could modify the `RedisClientOpt`, `RedisFailoverClientOpt`, and `RedisClusterClientOpt` structs behind the `RedisConnOpt` to support customized Dial, Read, and Write timeouts. Currently, the default values are passed when instantiating the `*asynq.Client`: - 5 seconds for Dial - 3 seconds for Read/Write In most circumstances, the defaults have been working fine, but I have gotten some `i/o timeout` errors during periods when the underlying redis server is under heavy load. Here's the current definition of the `RedisClientOpt`. I think adding fields for the respective timeouts should suffice. ```go // RedisClientOpt is used to create a redis client that connects // to a redis server directly. type RedisClientOpt struct { // Network type to use, either tcp or unix. // Default is tcp. Network string // Redis server address in "host:port" format. Addr string // Username to authenticate the current connection when Redis ACLs are used. // See: https://redis.io/commands/auth. Username string // Password to authenticate the current connection. // See: https://redis.io/commands/auth. Password string // Redis DB to select after connecting to a server. // See: https://redis.io/commands/select. DB int // Maximum number of socket connections. // Default is 10 connections per every CPU as reported by runtime.NumCPU. PoolSize int // TLS Config used to connect to a server. // TLS will be negotiated only if this field is set. TLSConfig *tls.Config } ```
kerem 2026-03-15 19:15:14 +03:00
Author
Owner

@hibiken commented on GitHub (Mar 24, 2021):

@dhh93 Thank you for opening this issue!

Make sense to add these options, it's included in the latest v0.17. release 👍

<!-- gh-comment-id:806257214 --> @hibiken commented on GitHub (Mar 24, 2021): @dhh93 Thank you for opening this issue! Make sense to add these options, it's included in the latest v0.17. release 👍
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asynq#2119
No description provided.