Class: Burrow::Server
- Inherits:
-
Object
- Object
- Burrow::Server
- Defined in:
- lib/burrow/server.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
-
#initialize(queue) ⇒ Server
constructor
A new instance of Server.
- #subscribe ⇒ Object
Constructor Details
#initialize(queue) ⇒ Server
Returns a new instance of Server.
5 6 7 |
# File 'lib/burrow/server.rb', line 5 def initialize(queue) @connection = Burrow::Connection.new(queue) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
3 4 5 |
# File 'lib/burrow/server.rb', line 3 def connection @connection end |
Instance Method Details
#subscribe ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/burrow/server.rb', line 9 def subscribe connection.queue.subscribe(block: true) do |delivery_info, properties, payload| request = JSON.parse(payload) result = yield [request['method'], request['params']] response = Burrow::Response.new(request['id'], result) publish_response(response, properties) end end |