Skip to content

Commit 098fda8

Browse files
committed
fix: make command timeout configurable
1 parent 6e1a065 commit 098fda8

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

shard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: redis-cluster
2-
version: 0.8.8
2+
version: 0.8.9
33
license: MIT
44
authors:
55
- maiha <maiha@wota.jp>

src/cluster/bootstrap.cr

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ module Redis::Cluster
99
pass : String? = nil,
1010
ssl : Bool = false,
1111
ssl_context : OpenSSL::SSL::Context::Client? = nil,
12-
reconnect : Bool = true do
12+
reconnect : Bool = true,
13+
command_timeout : Time::Span? = 10.seconds do
1314
def host
1415
if @host && @host =~ /:/
1516
raise "invalid hostname: #{@host}"
@@ -57,7 +58,7 @@ module Redis::Cluster
5758
end
5859
end
5960

60-
def copy(host : String? = nil, port : Int32? = nil, sock : String? = nil, pass : String? = nil, ssl : Bool? = nil, ssl_context : OpenSSL::SSL::Context::Client? = nil, reconnect : Bool? = nil)
61+
def copy(host : String? = nil, port : Int32? = nil, sock : String? = nil, pass : String? = nil, ssl : Bool? = nil, ssl_context : OpenSSL::SSL::Context::Client? = nil, reconnect : Bool? = nil, command_timeout : Time::Span? = nil)
6162
Bootstrap.new(
6263
host: host || @host,
6364
port: port || @port,
@@ -66,12 +67,13 @@ module Redis::Cluster
6667
ssl: ssl.nil? ? @ssl : ssl,
6768
ssl_context: ssl_context,
6869
reconnect: reconnect.nil? ? @reconnect : reconnect,
70+
command_timeout: command_timeout || @command_timeout,
6971
)
7072
end
7173

7274
def redis
7375
ssl_ctx = @ssl ? ssl_context : nil
74-
Redis.new(host: host, port: port, unixsocket: @sock, password: @pass, ssl: @ssl, ssl_context: ssl_ctx, reconnect: @reconnect, command_timeout: 10.seconds, connect_timeout: 10.seconds)
76+
Redis.new(host: host, port: port, unixsocket: @sock, password: @pass, ssl: @ssl, ssl_context: ssl_ctx, reconnect: @reconnect, command_timeout: @command_timeout, connect_timeout: 10.seconds)
7577
rescue err : Redis::CannotConnectError
7678
if sock?
7779
raise Redis::CannotConnectError.new("file://#{@sock}")

0 commit comments

Comments
 (0)