Class: TinyQ::Client
- Inherits:
-
Object
- Object
- TinyQ::Client
- Defined in:
- lib/tinyq/client.rb
Instance Attribute Summary collapse
-
#callbacks ⇒ Object
Returns the value of attribute callbacks.
Instance Method Summary collapse
- #connect(host, port) ⇒ Object
- #feed_funnel(bucket, funnel) ⇒ Object
- #get_message(funnel) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #onreply(&block) ⇒ Object
-
#put_message(bucket, message) ⇒ Object
Public API.
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
25 26 27 |
# File 'lib/tinyq/client.rb', line 25 def initialize @callbacks = [] end |
Instance Attribute Details
#callbacks ⇒ Object
Returns the value of attribute callbacks.
23 24 25 |
# File 'lib/tinyq/client.rb', line 23 def callbacks @callbacks end |
Instance Method Details
#connect(host, port) ⇒ Object
29 30 31 32 33 |
# File 'lib/tinyq/client.rb', line 29 def connect(host, port) @host, @port = host, port @connection = EM.connect @host, @port, TinyQ::ClientConnection @connection.client = self end |
#feed_funnel(bucket, funnel) ⇒ Object
53 54 55 56 |
# File 'lib/tinyq/client.rb', line 53 def feed_funnel(bucket, funnel) command = {:Command => "FeedFunnel", :Bucket => bucket, :Funnel => funnel} @connection.send_data("#{command.to_json}#{TinyQ::DELIMITER}") end |
#get_message(funnel) ⇒ Object
43 44 45 46 |
# File 'lib/tinyq/client.rb', line 43 def (funnel) command = {:Command => "GetMessages", :Funnel => funnel} @connection.send_data("#{command.to_json}#{TinyQ::DELIMITER}") end |
#onreply(&block) ⇒ Object
48 49 50 |
# File 'lib/tinyq/client.rb', line 48 def onreply(&block) @callbacks << block end |