Skip to content

Commit

Permalink
fixed the last merging bugs, added a test
Browse files Browse the repository at this point in the history
  • Loading branch information
purzelrakete committed Jun 10, 2008
1 parent be299c5 commit 7827adb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/workling/starling/client.rb
Expand Up @@ -8,7 +8,8 @@ class Client

def initialize
@starling_url = Workling::Starling.config[:listens_on]
@connection = ::MemCache.new(self.starling_url, Workling::Starling.config[:memcache_options])
options = [self.starling_url, Workling::Starling.config[:memcache_options]].compact
@connection = ::MemCache.new(*options)
end

def method_missing(method, *args)
Expand Down
2 changes: 1 addition & 1 deletion lib/workling/starling/poller.rb
Expand Up @@ -21,7 +21,7 @@ def logger
end

def listen

# Allow concurrency for our tasks
ActiveRecord::Base.allow_concurrency = true

Expand Down
6 changes: 3 additions & 3 deletions script/listen.rb
Expand Up @@ -10,15 +10,15 @@

ActiveRecord::Base.logger = Workling::Base.logger
ActionController::Base.logger = Workling::Base.logger
RAILS_DEFAULT_LOGGER = Workling::Base.logger

client = Workling::Starling::Poller.new(Workling::Starling::Routing::ClassAndMethodRouting.new)
poller = Workling::Starling::Poller.new(Workling::Starling::Routing::ClassAndMethodRouting.new)

trap(:INT) { exit }

begin
client.listen
poller.listen
ensure
puts '** No Worklings found.' if Workling::Discovery.discovered.blank?
puts '** Exiting'
end

Expand Down
2 changes: 1 addition & 1 deletion script/workling_starling_client
Expand Up @@ -8,7 +8,7 @@ options = {
:ARGV => ARGV,
:dir_mode => :normal,
:dir => 'log',
:log_output => true
:log_output => true,
:multiple => false,
:backtrace => true,
:monitor => true
Expand Down
8 changes: 8 additions & 0 deletions test/starling_client_test.rb
Expand Up @@ -10,4 +10,12 @@
client.connection.servers.first.port.should == 12345
client.connection.namespace.should.equal "myapp_development"
end

specify "should load it's config correctly if no memcache options are given" do
Workling::Starling.send :class_variable_set, "@@config", nil
YAML.expects(:load).returns({ "test" => { "listens_on" => "localhost:12345" } })

client = Workling::Starling::Client.new
client.starling_url.should.equal "localhost:12345"
end
end

0 comments on commit 7827adb

Please sign in to comment.