From 2760c0ee2c11a5b9125e5a07374f5fdd5a93282e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 4 Oct 2009 01:10:52 -0700 Subject: configuration default tweaks :Base is default (along with the implied worker_connections=1). This disallows nil for worker_connections, and makes. --- lib/rainbows/http_server.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'lib/rainbows/http_server.rb') 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 -- cgit v1.2.3-24-ge0c7