Skip to content

The time for acquire a new connection is not counted when setting context timeout for a query #798

Answered by rueian
liuzhaohui asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @liuzhaohui,

Yes, currently acquiring a connection doesn't respect the context deadline. To respect it, we need to update:

func dial(dst string, opt *ClientOption) (conn net.Conn, err error) {

the dial function to make it accept a context and use Dialer.DialContext to make a connection, and then we also need to update all the intermediate code paths that use the dial function under the hood.

Before that, you can set connection timeout at ClientOption.Dialer.Timeout:

	client, err := rueidis.NewClient(rueidis.ClientOption{
		Dialer: net.Dialer{
			Timeout: 30 * time.Millisecond,
		},
		BlockingPoolSize: 1024,
	})

Also note that you…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@liuzhaohui
Comment options

@rueian
Comment options

@liuzhaohui
Comment options

Answer selected by liuzhaohui
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants