Class: EventMachine::HandlerSocket::Client
- Inherits:
-
Connection
- Object
- Connection
- EventMachine::HandlerSocket::Client
- Includes:
- Deferrable, Protocols::LineProtocol
- Defined in:
- lib/em-handlersocket/client.rb
Instance Method Summary collapse
- #connection_completed ⇒ Object
- #delete(q) ⇒ Object
- #execute(cmd, &blk) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #insert(opts) ⇒ Object
- #open_index(opts) ⇒ Object
- #query(*qu) ⇒ Object
- #update(q) ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
37 38 39 |
# File 'lib/em-handlersocket/client.rb', line 37 def initialize @deferrables = [] end |
Instance Method Details
#connection_completed ⇒ Object
41 42 43 |
# File 'lib/em-handlersocket/client.rb', line 41 def connection_completed succeed end |
#delete(q) ⇒ Object
57 58 59 |
# File 'lib/em-handlersocket/client.rb', line 57 def delete(q) execute([[q[:id], q[:op], q[:key].size, q[:key], (q[:limit] || 1), (q[:offset] || 0), 'D']]) end |
#execute(cmd, &blk) ⇒ Object
65 66 67 68 |
# File 'lib/em-handlersocket/client.rb', line 65 def execute(cmd, &blk) callback { send(cmd) } add_deferrable(cmd.size, &blk) end |
#insert(opts) ⇒ Object
53 54 55 |
# File 'lib/em-handlersocket/client.rb', line 53 def insert(opts) execute([[opts[:id], '+', opts[:data].size, opts[:data]]]) end |
#open_index(opts) ⇒ Object
45 46 47 |
# File 'lib/em-handlersocket/client.rb', line 45 def open_index(opts) execute([['P', opts[:id], opts[:db], opts[:table], opts[:index_name], opts[:columns]]]) end |
#query(*qu) ⇒ Object
49 50 51 |
# File 'lib/em-handlersocket/client.rb', line 49 def query(*qu) execute(qu.map{|q| [q[:id], q[:op], q[:key].size, q[:key], q[:limit], q[:offset]].compact }) end |
#update(q) ⇒ Object
61 62 63 |
# File 'lib/em-handlersocket/client.rb', line 61 def update(q) execute([[q[:id], q[:op], q[:key].size, q[:key], (q[:limit] || 1), (q[:offset] || 0), 'U', q[:data]]]) end |