Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update tests #3

Merged
merged 7 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,34 @@ jobs:
--health-retries 5
ports:
# Maps port 6379 on service container to the host
- '6379:6379'
- "6379:6379"
strategy:
fail-fast: false
matrix:
ruby-version: ['2.7', '3.0', '3.1', '3.2']
gemfile: ['Gemfile', 'Gemfile.redis3', 'Gemfile.redis4']
ruby-version:
- "3.0"
- "3.1"
- "3.2"
- "3.3"
resque-version:
- "~> 1.23"
redis-version:
- "~> 3.3"
- "~> 4.8"
env:
# $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}
REDIS_VERSION: "${{ matrix.redis-version }}"
RESQUE: "${{ matrix.resque-version }}"
# The hostname used to communicate with the Redis service container
REDIS_TEST_HOST: localhost
# The default Redis port
REDIS_TEST_PORT: 6379
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Run tests
env:
# The hostname used to communicate with the Redis service container
REDIS_TEST_HOST: localhost
# The default Redis port
REDIS_TEST_PORT: 6379
run: bundle exec rake

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ coverage/
.bundle/
dump.rdb
stdout
.vscode
25 changes: 25 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,27 @@
source 'https://rubygems.org'

case resque_version = ENV.fetch('RESQUE', 'latest')
when 'master'
gem 'resque', git: 'https://github.com/resque/resque'
when /^git:/, /^https:/
gem 'resque', git: resque_version
when 'latest'
gem 'resque'
else
versions = resque_version.split(',')
gem 'resque', *versions
end

case redis_version = ENV.fetch('REDIS_VERSION', 'latest')
when 'master'
gem 'redis', git: 'https://github.com/redis/redis-rb'
when /^git:/, /^https:/
gem 'redis', git: redis_version
when 'latest'
gem 'redis'
else
versions = redis_version.split(',')
gem 'redis', *versions
end
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moves matrix into gemfile, out of separate files


gemspec
5 changes: 0 additions & 5 deletions Gemfile.redis3

This file was deleted.

5 changes: 0 additions & 5 deletions Gemfile.redis4

This file was deleted.

17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Resque Lock Timeout

A [Resque][rq] plugin. Requires Resque ~> 1.23.
A [Resque][rq] plugin. Requires Resque ~> 1.23, redis-rb >= 3.3, < 5.

This is a fork of [resque-lock-timeout][resque-lock-timeout] with testing and other fixes applied.

----------

resque-lock-timeout adds locking, with optional timeout/deadlock handling to resque jobs.

Expand Down Expand Up @@ -56,7 +60,7 @@ end

The locking algorithm used can be found in the [Redis SETNX][redis-setnx] documentation.

Simply set the lock timeout in seconds, e.g.
Set the lock timeout in seconds, e.g.

```ruby
class UpdateNetworkGraph
Expand All @@ -76,9 +80,9 @@ end

### Job Identifier/Lock Key

By default the key uses this format: `lock:<job class name>:<identifier>`.
By default, the key uses this format: `lock:<job class name>:<identifier>`.

The default identifier is just your job arguments joined with a dash `-`.
The default identifier is your job arguments joined with a dash `-`.

If you have a lot of arguments or really long ones, you should consider overriding `identifier` to define a more precise or loose custom identifier:

Expand Down Expand Up @@ -123,7 +127,7 @@ That would use the key `lock:updates`.

### Redis Connection Used for Locking

By default all locks are stored via Resque's redis connection. If you wish to change this you may override `lock_redis`.
By default, all locks are stored via Resque's redis connection. If you wish to change this you may override `lock_redis`.

```ruby
class UpdateNetworkGraph
Expand Down Expand Up @@ -165,7 +169,7 @@ end
- `enqueued?` - checks if the loner lock is currently held.
- `loner_locked?` - checks if the job is either enqueued (if a loner) or locked (any job).
- `refresh_lock!` - Refresh the lock, useful for jobs that are taking longer
then usual but your okay with them holding on to the lock a little longer.
then usual but you're okay with them holding on to the lock a little longer.

### Callbacks

Expand Down Expand Up @@ -221,3 +225,4 @@ Forked from [a little tinkering from Luke Antins](https://github.com/lantins/res
[redis-setnx]: http://redis.io/commands/setnx
[resque-lock]: http://github.com/defunkt/resque-lock
[resque-lock-retry]: http://github.com/rcarver/resque-lock-retry
[resque-lock-timeout]: https://github.com/lantins/resque-lock-timeout
22 changes: 12 additions & 10 deletions resque-lock-timeout.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "resque-lock-timeout"
s.version = "0.5.0"
s.name = "ibotta-resque-lock-timeout"
s.version = "0.5.1"
s.date = Time.now.strftime("%Y-%m-%d")
s.summary = "A Resque plugin adding locking, with optional timeout/deadlock handling to resque jobs."
s.license = "MIT"
Expand All @@ -14,19 +14,21 @@ Gem::Specification.new do |s|

s.add_dependency("resque", "~> 1.23")
s.add_dependency("redis", ">= 3.3", "< 5")

s.add_development_dependency("rake")
s.add_development_dependency("minitest")
s.add_development_dependency("yard")
s.add_development_dependency("simplecov")
s.add_development_dependency("debug")

s.description = <<DESC
A Resque plugin. Adds locking, with optional timeout/deadlock handling to
resque jobs.
s.description = <<-DESC
A Resque plugin. Adds locking, with optional timeout/deadlock handling to
resque jobs.

Using a `lock_timeout` allows you to re-acquire the lock should your worker
fail, crash, or is otherwise unable to relase the lock.
Using a `lock_timeout` allows you to re-acquire the lock should your worker
fail, crash, or is otherwise unable to relase the lock.

i.e. Your server unexpectedly loses power. Very handy for jobs that are
recurring or may be retried.
DESC
i.e. Your server unexpectedly loses power. Very handy for jobs that are
recurring or may be retried.
DESC
end
2 changes: 1 addition & 1 deletion test/lock_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_resque_plugin_lint
end

def test_version
major, minor, _patch = Resque::Version.split(".")
major, minor, _patch = Resque::VERSION.split(".")
assert_equal 1, major.to_i
assert minor.to_i >= 7
end
Expand Down