Class: Appfuel::Service::Worker
- Inherits:
-
Object
- Object
- Appfuel::Service::Worker
- Includes:
- Application::AppContainer, Application::Dispatcher, Sneakers::Worker
- Defined in:
- lib/appfuel/service/worker.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#publish_rpc(request, response) ⇒ Nil
Publish a response for the rpc request.
-
#work_with_params(msg, delivery_info, properties) ⇒ Appfuel::Response
Sneakers worker hook to handle messages from RabbitMQ.
Class Method Details
.container_class_type ⇒ Object
24 25 26 |
# File 'lib/appfuel/service/worker.rb', line 24 def container_class_type 'consumers' end |
.inherited(klass) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/appfuel/service/worker.rb', line 9 def inherited(klass) container = klass.app_container consumer_key = "#{klass.top_container_key}.consumer_keys" unless container.key?(consumer_key) container.register(consumer_key, []) end key = klass.container_class_path container.register(key, klass) container[consumer_key] << key end |
.top_container_key ⇒ Object
20 21 22 |
# File 'lib/appfuel/service/worker.rb', line 20 def top_container_key "message_brokers" end |
Instance Method Details
#publish_rpc(request, response) ⇒ Nil
Publish a response for the rpc request.
53 54 55 56 57 58 59 60 61 |
# File 'lib/appfuel/service/worker.rb', line 53 def publish_rpc(request, response) = { correlation_id: request.correlation_id, routing_key: request.reply_to, headers: { "action_route" => request.action_route } } publish(response.to_json, ) nil end |
#work_with_params(msg, delivery_info, properties) ⇒ Appfuel::Response
Sneakers worker hook to handle messages from RabbitMQ
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/appfuel/service/worker.rb', line 36 def work_with_params(msg, delivery_info, properties) container = app_container request = create_request(msg, delivery_info, properties) response = dispatch(request, container) if request.rpc? publish_rpc(request, response) end ack! end |