Class: Redis::Connection::RedisClient
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- Redis::Connection::RedisClient
- Includes:
- EventMachine::Deferrable
- Defined in:
- lib/redis/connection/synchrony.rb
Instance Method Summary collapse
- #connection_completed ⇒ Object
- #post_init ⇒ Object
- #read ⇒ Object
- #receive_data(data) ⇒ Object
- #send(data) ⇒ Object
- #unbind ⇒ Object
Instance Method Details
#connection_completed ⇒ Object
16 17 18 |
# File 'lib/redis/connection/synchrony.rb', line 16 def connection_completed succeed end |
#post_init ⇒ Object
11 12 13 14 |
# File 'lib/redis/connection/synchrony.rb', line 11 def post_init @req = nil @reader = ::Hiredis::Reader.new end |
#read ⇒ Object
32 33 34 35 |
# File 'lib/redis/connection/synchrony.rb', line 32 def read @req = EventMachine::DefaultDeferrable.new EventMachine::Synchrony.sync @req end |
#receive_data(data) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/redis/connection/synchrony.rb', line 20 def receive_data(data) @reader.feed(data) begin until (reply = @reader.gets) == false @req.succeed [:reply, reply] end rescue RuntimeError => err @req.fail [:error, ::Redis::ProtocolError.new(err.)] end end |
#send(data) ⇒ Object
37 38 39 |
# File 'lib/redis/connection/synchrony.rb', line 37 def send(data) callback { send_data data } end |
#unbind ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/redis/connection/synchrony.rb', line 41 def unbind if @req @req.fail [:error, Errno::ECONNRESET] @req = nil else fail end end |