Class: EasyBunnyRPC::Worker
- Inherits:
-
Object
- Object
- EasyBunnyRPC::Worker
- Defined in:
- lib/easy_bunny_rpc/worker.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(options = {}) ⇒ Worker
constructor
A new instance of Worker.
- #publish_failure(payload) ⇒ Object
- #publish_success(payload) ⇒ Object
- #subscribe ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Worker
Returns a new instance of Worker.
6 7 8 |
# File 'lib/easy_bunny_rpc/worker.rb', line 6 def initialize(={}) @options = end |
Instance Method Details
#close ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/easy_bunny_rpc/worker.rb', line 26 def close if defined?(@channel) channel.close remove_instance_variable :@channel remove_instance_variable :@queue end if defined?(@connection) connection.close remove_instance_variable :@connection end if defined?(@exchange) remove_instance_variable :@exchange end end |
#publish_failure(payload) ⇒ Object
14 15 16 |
# File 'lib/easy_bunny_rpc/worker.rb', line 14 def publish_failure(payload) publish false, payload end |
#publish_success(payload) ⇒ Object
10 11 12 |
# File 'lib/easy_bunny_rpc/worker.rb', line 10 def publish_success(payload) publish true, payload end |
#subscribe ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/easy_bunny_rpc/worker.rb', line 18 def subscribe queue.subscribe(block: true) do |delivery_info, properties, payload| @delivery_info, @properties, @payload = delivery_info, properties, payload yield JSON.parse(payload).first end end |