Skip to content

Commit

Permalink
No more Status#logger - Remove dependency on Redisk
Browse files Browse the repository at this point in the history
  • Loading branch information
quirkey committed Oct 21, 2012
1 parent d2aa154 commit c59b3b8
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 62 deletions.
1 change: 0 additions & 1 deletion Gemfile
@@ -1,6 +1,5 @@
source :rubygems

gem 'redisk', '>= 0.2.1'
gem 'resque', '~>1.19'

group :test do
Expand Down
22 changes: 9 additions & 13 deletions Gemfile.lock
Expand Up @@ -2,33 +2,30 @@ GEM
remote: http://rubygems.org/
specs:
git (1.2.5)
jeweler (1.8.3)
jeweler (1.8.4)
bundler (~> 1.0)
git (>= 1.2.5)
rake
rdoc
json (1.6.5)
json (1.7.5)
mocha (0.9.12)
multi_json (1.0.4)
multi_json (1.3.6)
rack (1.4.1)
rack-protection (1.2.0)
rack
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
redis (2.2.2)
redis-namespace (1.0.3)
redis (< 3.0.0)
redisk (0.2.2)
redis (>= 0.1.1)
redis-namespace (>= 0.1.0)
resque (1.19.0)
redis (3.0.2)
redis-namespace (1.2.1)
redis (~> 3.0.0)
resque (1.23.0)
multi_json (~> 1.0)
redis-namespace (~> 1.0.2)
redis-namespace (~> 1.0)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
shoulda (2.10.3)
sinatra (1.3.2)
sinatra (1.3.3)
rack (~> 1.3, >= 1.3.6)
rack-protection (~> 1.2)
tilt (~> 1.3, >= 1.3.3)
Expand All @@ -42,6 +39,5 @@ PLATFORMS
DEPENDENCIES
jeweler
mocha (~> 0.9.8)
redisk (>= 0.2.1)
resque (~> 1.19)
shoulda (~> 2.10.2)
7 changes: 0 additions & 7 deletions lib/resque/plugins/status.rb
Expand Up @@ -153,11 +153,9 @@ def safe_perform!
end
on_success if respond_to?(:on_success)
rescue Killed
logger.info "Job #{self} Killed at #{Time.now}"
Resque::Plugins::Status::Hash.killed(uuid)
on_killed if respond_to?(:on_killed)
rescue => e
logger.error e
failed("The task failed because of an error: #{e}")
if respond_to?(:on_failure)
on_failure(e)
Expand All @@ -166,11 +164,6 @@ def safe_perform!
end
end

# Returns a Redisk::Logger object scoped to this paticular job/uuid
def logger
@logger ||= Resque::Plugins::Status::Hash.logger(uuid)
end

# Set the jobs status. Can take an array of strings or hashes that are merged
# (in order) into a final status hash.
def status=(new_status)
Expand Down
13 changes: 0 additions & 13 deletions lib/resque/plugins/status/hash.rb
Expand Up @@ -75,15 +75,6 @@ def self.remove(uuid)
redis.del(status_key(uuid))
redis.zrem(set_key, uuid)
end
# returns a Redisk::Logger scoped to the UUID. Any options passed are passed
# to the logger initialization.
#
# Ensures that Redisk is logging to the same Redis connection as Resque.
def self.logger(uuid, options = {})
require 'redisk' unless defined?(Redisk)
Redisk.redis = redis
Redisk::Logger.new(logger_key(uuid), options)
end

def self.count
redis.zcard(set_key)
Expand Down Expand Up @@ -175,10 +166,6 @@ def self.kill_key
"_kill"
end

def self.logger_key(uuid)
"_log:#{uuid}"
end

def self.generate_uuid
SecureRandom.hex.to_s
end
Expand Down
2 changes: 0 additions & 2 deletions test/test_helper.rb
Expand Up @@ -4,7 +4,6 @@
require 'test/unit'
require 'rubygems'
require 'shoulda'
require 'redisk'
require 'mocha'

require 'resque-status'
Expand Down Expand Up @@ -46,7 +45,6 @@ class Test::Unit::TestCase
puts "Starting redis for testing at localhost:9736..."
`redis-server #{dir}/redis-test.conf`
Resque.redis = 'localhost:9736/1'
Redisk.redis = 'localhost:9736/1'

#### Fixtures

Expand Down
26 changes: 0 additions & 26 deletions test/test_resque_plugins_status_hash.rb
Expand Up @@ -190,32 +190,6 @@ class TestResquePluginsStatusHash < Test::Unit::TestCase
end

end

# context ".count" do
#
# should "return a count of statuses" do
# statuses = Resque::Plugins::Status::Hash.statuses
# assert_equal 2, statuses.size
# assert_equal statuses.size, Resque::Plugins::Status::Hash.count
# end
#
# end

context ".logger" do
setup do
@logger = Resque::Plugins::Status::Hash.logger(@uuid)
end

should "return a redisk logger" do
assert @logger.is_a?(Redisk::Logger)
end

should "scope the logger to a key" do
assert_match(/#{@uuid}/, @logger.name)
end

end

end

end

0 comments on commit c59b3b8

Please sign in to comment.