diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-10-28 06:52:36 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-10-28 06:52:36 +0000 |
commit | a667bc3787eaaf5b7df3b70624985d5fb5b8fc61 (patch) | |
tree | 7b364453627e2bdc4b737c5310abb8755f69222c /lib/yahns/config.rb | |
parent | 64dc231c557426f5729ad3b8b3d5a6693ca85ad2 (diff) | |
download | yahns-a667bc3787eaaf5b7df3b70624985d5fb5b8fc61.tar.gz |
We do not want users to use the default queue unless an app context requires it. We also do not want to spin up the default queue unless we are sure we have app contexts using it (and not private/anonymous queues).
Diffstat (limited to 'lib/yahns/config.rb')
-rw-r--r-- | lib/yahns/config.rb | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/yahns/config.rb b/lib/yahns/config.rb index c955e0f..e571cb7 100644 --- a/lib/yahns/config.rb +++ b/lib/yahns/config.rb @@ -38,7 +38,7 @@ class Yahns::Config # :nodoc: @config_listeners = {} # name/address -> options @app_ctx = [] @set = Hash.new(:unset) - @qeggs = {} + @qeggs = Hash.new { |h,k| h[k] = Yahns::QueueEgg.new } @app_instances = {} # set defaults: @@ -227,16 +227,23 @@ class Yahns::Config # :nodoc: /:/ =~ addr ? "[#{addr}]:#{port}" : "#{addr}:#{port}" end - def queue(name = :default, &block) + def queue(name = nil, &block) var = :queue - qegg = @qeggs[name] ||= Yahns::QueueEgg.new prev_block = @block - _check_in_block(:app, var) if prev_block + if prev_block + _check_in_block(:app, var) + name ||= @block + else + name ||= :default + end + qegg = @qeggs[name] if block_given? @block = CfgBlock.new(:queue, qegg) instance_eval(&block) @block = prev_block end + + # associate the queue if we're inside an app prev_block.ctx.qegg = qegg if prev_block end @@ -374,7 +381,7 @@ class Yahns::Config # :nodoc: val = @set[var] server.__send__("#{var}=", val) if val != :unset end - queue(:default) if @qeggs.empty? + @app_ctx.each { |app| app.logger ||= server.logger } end end |