summary refs log tree commit homepage
path: root/lib/rainbows/never_block.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-12-08 00:46:38 -0800
committerEric Wong <normalperson@yhbt.net>2009-12-08 00:46:38 -0800
commitc0df78a84bde010034970effee30700fd502a401 (patch)
treeccec3da85d99d22aa3239af5581abf9e9d71840c /lib/rainbows/never_block.rb
parentc4996358a9cd949757f297dfdcc2a71306fc285f (diff)
The last change to our EventMachine support code broke
our (lightly-tested) NeverBlock support badly.
Diffstat (limited to 'lib/rainbows/never_block.rb')
-rw-r--r--lib/rainbows/never_block.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/rainbows/never_block.rb b/lib/rainbows/never_block.rb
index 0933c73..06bb496 100644
--- a/lib/rainbows/never_block.rb
+++ b/lib/rainbows/never_block.rb
@@ -34,12 +34,14 @@ module Rainbows
       G.server.extend(Core)
     end
 
-    module Client
-
+    module Core
       def self.setup
-        const_set(:POOL, ::NB::Pool::FiberPool.new(O[:pool_size]))
-        Rainbows.const_get(O[:backend]).const_get(:Client).module_eval do
-          include Rainbows::NeverBlock::Client
+        self.const_set(:POOL, ::NB::Pool::FiberPool.new(O[:pool_size]))
+        base = O[:backend].to_s.gsub!(/([a-z])([A-Z])/, '\1_\2').downcase!
+        require "rainbows/never_block/#{base}"
+        Rainbows::NeverBlock.const_get(:Client).class_eval do
+          self.superclass.const_set(:APP, G.server.app)
+          include Rainbows::NeverBlock::Core
           alias _app_call app_call
           undef_method :app_call
           alias app_call nb_app_call
@@ -60,7 +62,7 @@ module Rainbows
     module Core
       def init_worker_process(worker)
         super
-        Client.setup
+        Core.setup
         logger.info "NeverBlock/#{O[:backend]} pool_size=#{O[:pool_size]}"
       end
     end