Class: HonestPubsub::Server::ClientQueueListener
- Inherits:
-
Object
- Object
- HonestPubsub::Server::ClientQueueListener
- Includes:
- Celluloid
- Defined in:
- lib/honest_pubsub/server/client_queue_listener.rb
Instance Attribute Summary collapse
-
#worker_class ⇒ Object
readonly
Returns the value of attribute worker_class.
Instance Method Summary collapse
-
#initialize(worker_class, request_key, queue, durable = true, topic = "honest") ⇒ ClientQueueListener
constructor
A new instance of ClientQueueListener.
- #message_received(delivery_info, properties, envelope) ⇒ Object
- #shutdown ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(worker_class, request_key, queue, durable = true, topic = "honest") ⇒ ClientQueueListener
Returns a new instance of ClientQueueListener.
13 14 15 16 17 18 19 20 |
# File 'lib/honest_pubsub/server/client_queue_listener.rb', line 13 def initialize(worker_class, request_key, queue, durable = true, topic = "honest") @topic = topic @request_key = request_key @worker_class = worker_class @queue_name = queue @durable = durable @subscriber = ::HonestPubsub::Subscriber.new(@request_key, @durable, @topic) end |
Instance Attribute Details
#worker_class ⇒ Object (readonly)
Returns the value of attribute worker_class.
11 12 13 |
# File 'lib/honest_pubsub/server/client_queue_listener.rb', line 11 def worker_class @worker_class end |
Instance Method Details
#message_received(delivery_info, properties, envelope) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/honest_pubsub/server/client_queue_listener.rb', line 36 def (delivery_info, properties, envelope) HonestPubsub.logger.debug("Message received by listener on #{worker_class.name} with payload: #{envelope[:payload]}") worker = worker_class.new(delivery_info, properties) worker.perform!(envelope[:context], envelope[:payload]) rescue => e HonestPubsub.logger.error("Failed message for #{worker_class.name}") Airbrake.notify("Failed perform for #{worker_class.name}", params: { info: delivery_info, properties: properties, context: envelope[:context], payload: envelope[:payload] }) end |
#shutdown ⇒ Object
29 30 31 32 33 34 |
# File 'lib/honest_pubsub/server/client_queue_listener.rb', line 29 def shutdown @subscriber.teardown if @subscriber.present? # TODO -thl # This the kosher thing to do in ruby? teardown end |
#start ⇒ Object
22 23 24 25 26 27 |
# File 'lib/honest_pubsub/server/client_queue_listener.rb', line 22 def start @subscriber.start(@queue_name, false) do |delivery_info, properties, envelope| (delivery_info, properties, envelope) true end end |