It's easy, just uncomment this line in application.rb:
config.middleware.insert_before Rails::Rack::Logger, Rack::FiberPool
题
I'm refactoring a ROR project which is using Faraday as request client and has predefined adapter to use with EM synchrony like this:
def which_faraday_adapter?
if Utils::ModuleLoaded.synchrony? && Utils::ModuleLoaded.fiberpool?
:em_synchrony
else
:net_http
end
end
module ModuleLoaded
def self.synchrony?
defined?(EM::Synchrony) && EM.reactor_running?
end
def self.fiberpool?
CfConsole::Application.config.middleware.middlewares.include?(Rack::FiberPool)
end
end
I know I can enable FiberPool in my config/application.rb, but how can I enable EM.synchrony?
I'm new in ruby with basic knowledge of EM but I'm still not very clear about the meaning of:
defined?(EM::Synchrony) && EM.reactor_running?
So any explanations and samples are really appreciated.
解决方案
It's easy, just uncomment this line in application.rb:
config.middleware.insert_before Rails::Rack::Logger, Rack::FiberPool