Skip to content

Commit

Permalink
Merge pull request #24 from drfeelngood/resque-helpers-deprecated
Browse files Browse the repository at this point in the history
Deprecated inclusion of Resque::Helpers.
  • Loading branch information
drfeelngood committed Feb 14, 2015
2 parents c8e65b5 + e5806e2 commit d24aa35
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions lib/resque/plugins/batched_job.rb
Expand Up @@ -20,8 +20,6 @@ module Plugins

module BatchedJob

include Resque::Helpers

# Helper method used to generate the batch key.
#
# @param [Object, #to_s] id Batch identifier. Any Object that responds to #to_s
Expand All @@ -35,7 +33,7 @@ def batch(id)
# @param [Object, #to_s] id Batch identifier. Any Object that responds to #to_s
def after_enqueue_batch(id, *args)
mutex(id) do |bid|
redis.rpush(bid, encode(:class => self.name, :args => args))
redis.rpush(bid, Resque.encode(:class => self.name, :args => args))
end
end

Expand Down Expand Up @@ -85,7 +83,7 @@ def batch_exist?(id)
# @param id (see Resque::Plugins::BatchedJob#after_enqueue_batch)
def remove_batched_job(id, *args)
mutex(id) do |bid|
redis.lrem(bid, 1, encode(:class => self.name, :args => args))
redis.lrem(bid, 1, Resque.encode(:class => self.name, :args => args))
redis.llen(bid)
end
end
Expand All @@ -106,7 +104,7 @@ def batched_jobs(id)
bid = batch(id)
regexp = /\A\{\"class\":\"#{self.name}\",\"args\":\[/
redis.lrange(bid, 0, redis.llen(bid)-1).grep(regexp).map do |string|
payload = decode(string)
payload = Resque.decode(string)
payload['args'].unshift(id)
Resque::Job.new(@queue, payload)
end
Expand All @@ -124,6 +122,10 @@ def recreate_batched_jobs(id)

private

def redis
Resque.redis
end

# Lock a batch key before executing Redis commands. This will ensure
# no race conditions occur when modifying batch information. Here is
# an example of how this works. See http://redis.io/commands/setnx for
Expand Down
2 changes: 1 addition & 1 deletion resque-batched-job.gemspec
Expand Up @@ -24,7 +24,7 @@ DESC
'lib/resque/plugins/batched_job.rb',
'lib/resque/plugins/batched_job/version.rb' ]

s.add_dependency "resque", ">= 1.10.0"
s.add_dependency "resque", ">= 1.25.0"

s.add_development_dependency "turn"
s.add_development_dependency "minitest"
Expand Down

0 comments on commit d24aa35

Please sign in to comment.