From febabe3dcfd1ee41cc253ca43fd667c9e2ec6444 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 1 Nov 2013 00:05:14 +0000 Subject: config: allow Float for timeouts Some users may care to have sub-second or fractional timeouts for various reasons. Do not reject those values to be consistent with Ruby sleep/select. --- lib/yahns/config.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/yahns/config.rb b/lib/yahns/config.rb index 29f5746..1862eee 100644 --- a/lib/yahns/config.rb +++ b/lib/yahns/config.rb @@ -76,7 +76,7 @@ class Yahns::Config # :nodoc: def shutdown_timeout(sec) var = _check_in_block(nil, :shutdown_timeout) - @set[var] = _check_int(var, sec, 0) + @set[var] = _check_num(var, sec, 0) end def worker_processes(nr, &blk) @@ -283,6 +283,12 @@ class Yahns::Config # :nodoc: n end + def _check_num(var, n, min) + Numeric === n or raise ArgumentError, "not a number: #{var}=#{n.inspect}" + n >= min or raise ArgumentError, "too low (< #{min}): #{var}=#{n.inspect}" + n + end + # global def client_expire_threshold(val) var = _check_in_block(nil, :client_expire_threshold) @@ -345,7 +351,6 @@ class Yahns::Config # :nodoc: client_body_buffer_size: 1, client_header_buffer_size: 1, client_max_header_size: 1, - client_timeout: 0, }.each do |_v,minval| eval( %Q(def #{_v}(val);) << @@ -355,6 +360,11 @@ class Yahns::Config # :nodoc: ) end + def client_timeout(val) + var = _check_in_block(:app, :client_timeout) + @block.ctx.__send__("#{var}=", _check_num(var, val, 0)) + end + def client_max_body_size(val) var = _check_in_block(:app, :client_max_body_size) val = _check_int(var, val, 0) if val != nil -- cgit v1.2.3-24-ge0c7