Skip to content

Commit

Permalink
Merge pull request #11 from adgear/fix/PEDSP-0000-rack-version-bump
Browse files Browse the repository at this point in the history
[PEDSP-0000] Update rack from 2.2.5 -> 2.2.9
  • Loading branch information
k-kumawat authored Jul 9, 2024
2 parents 7ae884a + dd86132 commit 115bb6d
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 48 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

strategy:
matrix:
ruby-version: ['2.6.10', '3.0']
ruby-version: ['2.7.7', '3.0']
steps:
- uses: actions/checkout@v3
- name: Set up Ruby ${{ matrix.ruby-version }}
Expand All @@ -39,7 +39,7 @@ jobs:
name: linters / rubocop
runs-on: ubuntu-latest
env:
RUBY_VERSION: 2.6.10
RUBY_VERSION: 2.7.7
steps:
- name: Codebase Checkout
uses: actions/checkout@v3
Expand All @@ -52,9 +52,4 @@ jobs:
cache-version: 1

- name: rubocop
uses: reviewdog/[email protected]
with:
rubocop_version: gemfile
rubocop_extensions: rubocop-performance rubocop-rake rubocop-i18n
reporter: github-check
fail_on_error: true
run: bundle exec rubocop
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
AllCops:
TargetRubyVersion: 2.6
TargetRubyVersion: 2.7
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ source 'https://rubygems.org'

gemspec

gem "resque"
gem 'resque'

group :development do
gem "rake"
gem "test-unit"
gem 'rake'
gem 'test-unit'
end
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ GEM
parser (3.2.0.0)
ast (~> 2.4.1)
power_assert (2.0.3)
rack (2.2.5)
rack (2.2.9)
rack-protection (3.0.5)
rack
rainbow (3.1.1)
Expand Down
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rake/testtask'
require 'rdoc/task'

Expand All @@ -9,7 +11,7 @@ end
# Tests
#

task :default => :test
task default: :test

Rake::TestTask.new do |t|
t.libs << 'lib'
Expand Down
18 changes: 8 additions & 10 deletions lib/resque/plugins/lock.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Resque
module Plugins
# If you want only one instance of your job queued at a time,
Expand Down Expand Up @@ -41,7 +43,6 @@ module Plugins
# repo_id. Normally a job is locked using a combination of its
# class name and arguments.
module Lock

# Override in your job to control the lock experiation time. This is the
# time in seconds that the lock should be considered valid. The default
# is one hour (3600 seconds).
Expand All @@ -53,7 +54,7 @@ def lock_timeout
# passed the same arguments as `perform`, that is, your job's
# payload.
def lock(*args)
"lock:#{name}-#{args.to_s}"
"lock:#{name}-#{args}"
end

# See the documentation for SETNX http://redis.io/commands/setnx for an
Expand All @@ -77,15 +78,12 @@ def before_enqueue_lock(*args)
end

def around_perform_lock(*args)
begin
yield
ensure
# Always clear the lock when we're done, even if there is an
# error.
Resque.redis.del(lock(*args))
end
yield
ensure
# Always clear the lock when we're done, even if there is an
# error.
Resque.redis.del(lock(*args))
end
end
end
end

43 changes: 23 additions & 20 deletions resque-lock.gemspec
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
# frozen_string_literal: true

Gem::Specification.new do |s|
s.name = "resque-lock"
s.version = "1.1.0"
s.required_ruby_version = '>= 2.7'
s.name = 'resque-lock'
s.version = '1.1.0'
s.date = Time.now.strftime('%Y-%m-%d')
s.summary = "A Resque plugin for ensuring only one instance of your job is queued at a time."
s.homepage = "http://github.com/defunkt/resque-lock"
s.email = "[email protected]"
s.authors = [ "Chris Wanstrath", "Ray Krueger" ]
s.summary = 'A Resque plugin for ensuring only one instance of your job is queued at a time.'
s.homepage = 'http://github.com/defunkt/resque-lock'
s.email = '[email protected]'
s.authors = ['Chris Wanstrath', 'Ray Krueger']
s.has_rdoc = false

s.files = %w( README.md Rakefile LICENSE )
s.files += Dir.glob("lib/**/*")
s.files += Dir.glob("test/**/*")
s.files = %w[README.md Rakefile LICENSE]
s.files += Dir.glob('lib/**/*')
s.files += Dir.glob('test/**/*')

s.description = <<desc
A Resque plugin. If you want only one instance of your job
queued at a time, extend it with this module.
s.description = <<~DESC
A Resque plugin. If you want only one instance of your job
queued at a time, extend it with this module.
For example:
For example:
class UpdateNetworkGraph
extend Resque::Jobs::Locked
class UpdateNetworkGraph
extend Resque::Jobs::Locked
def self.perform(repo_id)
heavy_lifting
end
end
desc
def self.perform(repo_id)
heavy_lifting
end
end
DESC

s.add_development_dependency 'rubocop', '~> 1.41.1'
end
10 changes: 6 additions & 4 deletions test/lock_test.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# frozen_string_literal: true

require 'test-unit'
require 'resque'
require 'resque/plugins/lock'

$counter = 0
$counter = 0 # rubocop:disable Style/GlobalVars

class LockTest < Test::Unit::TestCase
class Job
Expand Down Expand Up @@ -43,14 +45,14 @@ def test_lock
assert_equal 1, Resque.redis.llen('queue:lock_test')
end

def test_deadlock
def test_deadlock # rubocop:disable Metrics/AbcSize
now = Time.now.to_i

Resque.redis.set(Job.lock, now+60)
Resque.redis.set(Job.lock, now + 60)
Resque.enqueue(Job)
assert_equal 0, Resque.redis.llen('queue:lock_test')

Resque.redis.set(Job.lock, now-1)
Resque.redis.set(Job.lock, now - 1)
Resque.enqueue(Job)
assert_equal 1, Resque.redis.llen('queue:lock_test')

Expand Down

0 comments on commit 115bb6d

Please sign in to comment.