class Stealth::Dispatcher
Responsible for coordinating incoming messages
1. Receives incoming request params 2. Initializes respective service request handler 3. Processes params through service request handler (might be async) 4. Inits base StealthController with state params returned from the service request handler 5. Returns an HTTP response to be returned to the requestor
Attributes
headers[R]
message_handler[R]
params[R]
service[R]
Public Class Methods
new(service:, params:, headers:)
click to toggle source
# File lib/stealth/dispatcher.rb, line 17 def initialize(service:, params:, headers:) @service = service @params = params @headers = headers @message_handler = message_handler_klass.new( params: params, headers: headers ) end
Public Instance Methods
coordinate()
click to toggle source
# File lib/stealth/dispatcher.rb, line 27 def coordinate message_handler.coordinate end
process()
click to toggle source
# File lib/stealth/dispatcher.rb, line 31 def process service_message = message_handler.process bot_controller = BotController.new(service_message: service_message) bot_controller.route end
Private Instance Methods
message_handler_klass()
click to toggle source
# File lib/stealth/dispatcher.rb, line 39 def message_handler_klass begin Kernel.const_get("Stealth::Services::#{service.classify}::MessageHandler") rescue NameError raise(Stealth::Errors::ServiceNotRecognized, "The service '#{service}' was not recognized") end end