class Redis::Connection::RedisClient

Attributes

timeout[RW]

Public Instance Methods

connected?() click to toggle source
# File lib/redis/connection/synchrony.rb, line 33
def connected?
  @connected
end
connection_completed() click to toggle source
# File lib/redis/connection/synchrony.rb, line 28
def connection_completed
  @connected = true
  succeed
end
post_init() click to toggle source
# File lib/redis/connection/synchrony.rb, line 22
def post_init
  @req = nil
  @connected = false
  @reader = ::Hiredis::Reader.new
end
read() click to toggle source
# File lib/redis/connection/synchrony.rb, line 55
def read
  @req = EventMachine::DefaultDeferrable.new
  @req.timeout(@timeout, :timeout) if @timeout > 0
  EventMachine::Synchrony.sync @req
end
receive_data(data) click to toggle source
# File lib/redis/connection/synchrony.rb, line 37
def receive_data(data)
  @reader.feed(data)

  loop do
    begin
      reply = @reader.gets
    rescue RuntimeError => err
      @req.fail [:error, ProtocolError.new(err.message)]
      break
    end

    break if reply == false

    reply = CommandError.new(reply.message) if reply.is_a?(RuntimeError)
    @req.succeed [:reply, reply]
  end
end
send(data) click to toggle source
# File lib/redis/connection/synchrony.rb, line 61
def send(data)
  callback { send_data data }
end
unbind() click to toggle source
# File lib/redis/connection/synchrony.rb, line 65
def unbind
  @connected = false
  if @req
    @req.fail [:error, Errno::ECONNRESET]
    @req = nil
  else
    fail
  end
end