diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-03 16:14:57 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-03 16:17:16 -0700 |
commit | 5b14ec54da4b3dcd52c8755b6a036e5e94a565d1 (patch) | |
tree | ea90c4450dee5442fbcb9a804513211b2f035af0 | |
parent | a86d3be33ef2b433370df66d2ba026ab03b305b7 (diff) | |
download | rainbows-5b14ec54da4b3dcd52c8755b6a036e5e94a565d1.tar.gz |
They're similar enough (especially as far as the constants go) and allows a :Base to be used which basically acts like plain Unicorn but with HTTP keepalive + pipelining support
-rw-r--r-- | lib/rainbows.rb | 2 | ||||
-rw-r--r-- | lib/rainbows/base.rb (renamed from lib/rainbows/thread_base.rb) | 16 | ||||
-rw-r--r-- | lib/rainbows/revactor.rb | 4 | ||||
-rw-r--r-- | lib/rainbows/thread_pool.rb | 4 |
4 files changed, 15 insertions, 11 deletions
diff --git a/lib/rainbows.rb b/lib/rainbows.rb index f79c1e8..611c0ec 100644 --- a/lib/rainbows.rb +++ b/lib/rainbows.rb @@ -11,9 +11,9 @@ module Rainbows require 'rainbows/const' require 'rainbows/http_server' require 'rainbows/http_response' + require 'rainbows/base' autoload :Revactor, 'rainbows/revactor' - autoload :ThreadBase, 'rainbows/thread_base' autoload :ThreadPool, 'rainbows/thread_pool' class << self diff --git a/lib/rainbows/thread_base.rb b/lib/rainbows/base.rb index 52abac3..0e5843d 100644 --- a/lib/rainbows/thread_base.rb +++ b/lib/rainbows/base.rb @@ -2,13 +2,15 @@ module Rainbows - module ThreadBase + # base class for Rainbows concurrency models + module Base include Unicorn include Rainbows::Const - # write a response without caring if it went out or not - # This is in the case of untrappable errors + # write a response without caring if it went out or not for error + # messages. + # TODO: merge into Unicorn::HttpServer def emergency_response(client, response_str) client.write_nonblock(response_str) rescue nil client.close rescue nil @@ -56,6 +58,12 @@ module Rainbows logger.error "Read error: #{e.inspect}" logger.error e.backtrace.join("\n") end + + def self.included(klass) + HttpServer.constants.each do |x| + klass.const_set(x, HttpServer.const_get(x)) + end + end + end end - diff --git a/lib/rainbows/revactor.rb b/lib/rainbows/revactor.rb index d2e28ff..f602183 100644 --- a/lib/rainbows/revactor.rb +++ b/lib/rainbows/revactor.rb @@ -10,9 +10,7 @@ module Rainbows module Revactor require 'rainbows/revactor/tee_input' - include Unicorn - include Rainbows::Const - HttpServer.constants.each { |x| const_set(x, HttpServer.const_get(x)) } + include Base # once a client is accepted, it is processed in its entirety here # in 3 easy steps: read request, call app, write app response diff --git a/lib/rainbows/thread_pool.rb b/lib/rainbows/thread_pool.rb index 104bd38..e12559a 100644 --- a/lib/rainbows/thread_pool.rb +++ b/lib/rainbows/thread_pool.rb @@ -4,9 +4,7 @@ module Rainbows module ThreadPool - include ThreadBase - - HttpServer.constants.each { |x| const_set(x, HttpServer.const_get(x)) } + include Base def worker_loop(worker) init_worker_process(worker) |