Class: Magellan::Worker::Executor
- Inherits:
-
Object
- Object
- Magellan::Worker::Executor
- Defined in:
- lib/magellan/worker/executor.rb
Instance Method Summary collapse
- #execute(reply_to, correlation_id, delivery_tag, request_message) ⇒ Object
-
#initialize(exchange) ⇒ Executor
constructor
A new instance of Executor.
- #rails_executor ⇒ Object
- #subscriber_executor ⇒ Object
Constructor Details
#initialize(exchange) ⇒ Executor
Returns a new instance of Executor.
7 8 9 10 11 12 13 14 15 |
# File 'lib/magellan/worker/executor.rb', line 7 def initialize(exchange) @exchange = exchange @rails_executor = nil @subscriber_executor = nil # Rails 環境の初期化は Subscriber だけの時も実施する # Rails.root やら Rails.application.config がないと困ることが多いと思うので require File.('config/environment') end |
Instance Method Details
#execute(reply_to, correlation_id, delivery_tag, request_message) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/magellan/worker/executor.rb', line 25 def execute(reply_to, correlation_id, delivery_tag, ) version = ["v"] || 1 case version when 1 request_method = ["headers"]["Method"] request_id = ["headers"]["Magellan-Request-Id"] when 2 request_method = ["env"]["METHOD"] request_id = ["env"]["REQUEST_ID"] else raise "Unsupported request format version: #{version}. Please update magellan-rails." end Magellan.logger.info("Magellan requested with `#{request_id}`") case request_method when /\Apublish\z/i subscriber_executor.execute() else rails_executor.execute(reply_to, correlation_id, delivery_tag, ) end end |
#rails_executor ⇒ Object
17 18 19 |
# File 'lib/magellan/worker/executor.rb', line 17 def rails_executor @rails_executor ||= Magellan::Rails::Executor.new(@exchange) end |
#subscriber_executor ⇒ Object
21 22 23 |
# File 'lib/magellan/worker/executor.rb', line 21 def subscriber_executor @subscriber_executor ||= Magellan::Subscriber::Executor.new end |