redis-rb
redis-rb copied to clipboard
Provide separate connection timeout and response timeout options
Currently the :timeout option to the Redis constructor applies a latency ceiling both to the initial connection to the Redis server and to any responses to requests. This means you can't easily fail a connection within 1ms but fail a response (assuming the client successfully connected) that takes longer than 300ms.
Also, the error message is always Redis::TimeoutError: Connection timed out, even if the client successfully connected and the response timed out. This is highly misleading.
Would love this feature.
There should be a :connection_timeout in the options that is used by the drivers.
I'd be all for an additional :connection_timeout parameter when constructing a new client. For legacy reasons, this should default to the value for :timeout.
Implementing separate exceptions for the connection-timeout and the command-timeout will be a bit tricky to do in a backwards-compatible way, since consumers of this library have historically relied on this one exception to mean both things and have handled it accordingly.
If you're willing to submit a pull-request, I would definitely work with you to get the proposed feature merged :+1:
Implementing separate exceptions for the connection-timeout and the command-timeout will be a bit tricky to do in a backwards-compatible way, since consumers of this library have historically relied on this one exception to mean both things and have handled it accordingly.
Tricky? Do you mean impossible? :)
:connect_timeout is already in master.
If there is :connect_timeout, so not obvious the meaning of :timeout, isn't it?
I'd love to see:
- timeout deprecated and replaced with
read_timeout, the same term as used by Net::HTTP. - the README updated to document the timeout options.
I will do this soon unless a committer objects.
This has been solved for a while.