stefanwille / crystal-redis

Full featured Redis client for Crystal
MIT License
380 stars 61 forks source link

[suggestions] - please add support for disconnect / connection timeout #53

Closed ghost closed 6 years ago

ghost commented 6 years ago

for example, if you do

puts "Connecting to Redis..."
begin
    redis = Redis.new
    puts "Connected to Redis: #{redis}"
rescue e
  abort "Failed to connect to Redis Server: #{e}"
end

the user will never get a raised error about failed to connect. in fact, the above code will block (unless u put it into a fiber)

my suggestion:

ty for your time

stefanwille commented 6 years ago

Should not be too difficult:

TCPSocket.new(host, port, dns_timeout = nil, connect_timeout = nil)

ghost commented 6 years ago

@stefanwille i added tcpsocket = TCPSocket.new(host, port, false, 1)

to line 16, in connection.cr. and the redis error "connection timeout" dose get raised. =]

i am very new to crystal, so please take my ideas/posts with grain of salt. i'm still learning the ropes, thank you sir. great repo.

e: btw, im on Windows 10 using WSL. if that helps