diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-04 01:10:52 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-04 01:10:52 -0700 |
commit | 2760c0ee2c11a5b9125e5a07374f5fdd5a93282e (patch) | |
tree | 40cb5249856419a8f18684f580ae631a9cb22bd7 /lib/rainbows | |
parent | d815b6c9533bfe7dac868ae6d43161dfaac9fab3 (diff) | |
download | rainbows-2760c0ee2c11a5b9125e5a07374f5fdd5a93282e.tar.gz |
:Base is default (along with the implied worker_connections=1). This disallows nil for worker_connections, and makes.
Diffstat (limited to 'lib/rainbows')
-rw-r--r-- | lib/rainbows/http_server.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/rainbows/http_server.rb b/lib/rainbows/http_server.rb index 8ed8fa2..8fdecb6 100644 --- a/lib/rainbows/http_server.rb +++ b/lib/rainbows/http_server.rb @@ -15,30 +15,30 @@ module Rainbows def initialize(app, options) @@instance = self + @worker_connections = 1 rv = super(app, options) - defined?(@use) or use(:ThreadPool) - defined?(@worker_connections) or worker_connections(4) - rv + defined?(@use) or use(:Base) end def use(*args) - return @use if args.empty? - model = begin - Rainbows.const_get(args.first) + model = args.shift or return @use + mod = begin + Rainbows.const_get(model) rescue NameError raise ArgumentError, "concurrency model #{model.inspect} not supported" end - Module === model or + Module === mod or raise ArgumentError, "concurrency model #{model.inspect} not supported" - extend(@use = model) + extend(mod) + @use = model end def worker_connections(*args) return @worker_connections if args.empty? nr = args.first - (Integer === nr && nr > 0) || nr.nil? or - raise ArgumentError, "worker_connections must be an Integer or nil" + (Integer === nr && nr > 0) or + raise ArgumentError, "worker_connections must be a positive Integer" @worker_connections = nr end |