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
- #connected? ⇒ Boolean
- #connection_completed ⇒ Object
- #post_init ⇒ Object
- #read ⇒ Object
- #receive_data(data) ⇒ Object
- #send(data) ⇒ Object
- #unbind ⇒ Object
Instance Method Details
#connected? ⇒ Boolean
22 23 24 |
# File 'lib/redis/connection/synchrony.rb', line 22 def connected? @connected end |
#connection_completed ⇒ Object
17 18 19 20 |
# File 'lib/redis/connection/synchrony.rb', line 17 def connection_completed @connected = true succeed end |
#post_init ⇒ Object
11 12 13 14 15 |
# File 'lib/redis/connection/synchrony.rb', line 11 def post_init @req = nil @connected = false @reader = ::Hiredis::Reader.new end |
#read ⇒ Object
38 39 40 41 |
# File 'lib/redis/connection/synchrony.rb', line 38 def read @req = EventMachine::DefaultDeferrable.new EventMachine::Synchrony.sync @req end |
#receive_data(data) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/redis/connection/synchrony.rb', line 26 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
43 44 45 |
# File 'lib/redis/connection/synchrony.rb', line 43 def send(data) callback { send_data data } end |
#unbind ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/redis/connection/synchrony.rb', line 47 def unbind @connected = false if @req @req.fail [:error, Errno::ECONNRESET] @req = nil else fail end end |