From 9b90f34cdc2c7c462e2e20028b115209e9748969 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 14 Apr 2009 11:18:02 -0500 Subject: Using a setting for configuring queueing Removing class methods and such, and switching to relying solely on a setting for the queue configuration. Signed-off-by: Luke Kanies --- lib/puppet/defaults.rb | 3 ++- lib/puppet/indirector/queue.rb | 1 - lib/puppet/util/queue.rb | 14 ++++---------- spec/unit/indirector/queue.rb | 2 +- spec/unit/util/queue.rb | 15 ++++----------- 5 files changed, 11 insertions(+), 24 deletions(-) diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index ac7281356..3454f02dd 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -162,7 +162,8 @@ module Puppet "The minimum time to wait (in seconds) between checking for updates in configuration files. This timeout determines how quickly Puppet checks whether a file (such as manifests or templates) has changed on disk." - ] + ], + :queue_type => ["stomp", "Which type of queue to use for asynchronous processing."] ) hostname = Facter["hostname"].value diff --git a/lib/puppet/indirector/queue.rb b/lib/puppet/indirector/queue.rb index c58af9814..91e431795 100644 --- a/lib/puppet/indirector/queue.rb +++ b/lib/puppet/indirector/queue.rb @@ -20,7 +20,6 @@ require 'yaml' # creation is automatic and not a concern). class Puppet::Indirector::Queue < Puppet::Indirector::Terminus extend ::Puppet::Util::Queue - self.queue_type_default = :stomp # Queue has no idiomatic "find" def find(request) diff --git a/lib/puppet/util/queue.rb b/lib/puppet/util/queue.rb index 3724bab92..ce462ac66 100644 --- a/lib/puppet/util/queue.rb +++ b/lib/puppet/util/queue.rb @@ -23,9 +23,6 @@ require 'puppet/util/instance_loader' # class Queue::Fue # # mix it in at the class object level rather than instance level # extend ::Puppet::Util::Queue -# -# # specify the default client type to use. -# self.queue_type_default = :special_magical_type # end # # Queue::Fue instances can get a message queue client through the registry through the mixed-in method @@ -38,7 +35,6 @@ require 'puppet/util/instance_loader' # * _queue_ names are simple names independent of the message broker or client library. No "/queue/" prefixes like in Stomp::Client. module Puppet::Util::Queue extend Puppet::Util::InstanceLoader - attr_accessor :queue_type_default instance_load :queue_clients, 'puppet/util/queue' # Adds a new class/queue-type pair to the registry. The _type_ argument is optional; if not provided, @@ -84,13 +80,11 @@ module Puppet::Util::Queue end # The class object for the client to be used, determined by queue configuration - # settings and known queue client types. - # Looked to the :queue_client configuration entry in the running application for - # the default queue type to use, and fails over to +queue_type_default+ if the configuration - # information is not present. + # settings. + # Looks to the :queue_type configuration entry in the running application for + # the default queue type to use. def client_class - Puppet::Util::Queue.queue_type_to_class(Puppet[:queue_client] || queue_type_default) - # Puppet::Util::Queue.queue_type_to_class(Puppet[:queue_client] || :stomp) + Puppet::Util::Queue.queue_type_to_class(Puppet[:queue_type]) end # Returns (instantiating as necessary) the singleton queue client instance, according to the diff --git a/spec/unit/indirector/queue.rb b/spec/unit/indirector/queue.rb index de9a27fb2..0e9074440 100755 --- a/spec/unit/indirector/queue.rb +++ b/spec/unit/indirector/queue.rb @@ -46,7 +46,7 @@ describe Puppet::Indirector::Queue do @subject.name = :me Puppet.settings.stubs(:value).returns("bogus setting data") - Puppet.settings.stubs(:value).with(:queue_client).returns(:test_client) + Puppet.settings.stubs(:value).with(:queue_type).returns(:test_client) Puppet::Util::Queue.stubs(:queue_type_to_class).with(:test_client).returns(Puppet::Indirector::Queue::TestClient) Puppet::Indirector::Queue::TestClient.reset diff --git a/spec/unit/util/queue.rb b/spec/unit/util/queue.rb index 525e6239f..19af9430e 100755 --- a/spec/unit/util/queue.rb +++ b/spec/unit/util/queue.rb @@ -26,7 +26,6 @@ describe Puppet::Util::Queue do before :each do @class = Class.new do extend mod - self.queue_type_default = :default end end @@ -80,16 +79,10 @@ describe Puppet::Util::Queue do end context 'when determining client type' do - it 'returns client class based on queue_type_default' do - Puppet.settings.stubs(:value).returns(nil) - @class.client_class.should == client_classes[:default] - @class.client.class.should == client_classes[:default] - end - - it 'prefers settings variable for client class when specified' do - Puppet.settings.stubs(:value).with(:queue_client).returns(:setup) - @class.client_class.should == client_classes[:setup] - @class.client.class.should == client_classes[:setup] + it 'returns client class based on the :queue_type setting' do + Puppet.settings.expects(:value).with(:queue_type).returns(:myqueue) + Puppet::Util::Queue.expects(:queue_type_to_class).with(:myqueue).returns "eh" + @class.client_class.should == "eh" end end end -- cgit