Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: [2.5, 2.6, 2.7]
ruby-version: [3.4.1]
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.5
ruby-version: 3.4.1
bundler-cache: true
- name: Run Rubocop Linter
run: bundle exec rubocop
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AllCops:
TargetRubyVersion: 2.5
TargetRubyVersion: 3.4.1
NewCops: enable
SuggestExtensions: false

Expand Down
8 changes: 8 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ source "https://rubygems.org"

# Specify your gem's dependencies in potlock.gemspec
gemspec

group :development, :test do
gem "mock_redis", "~> 0.2"
gem "rake", "~> 13.0"
gem "rspec", "~> 3.0"
gem "rubocop", "~> 1.7"
gem "rubocop-rspec", "~> 2.4"
end
100 changes: 60 additions & 40 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,59 +1,79 @@
PATH
remote: .
specs:
potlock (0.3.0)
potlock (0.4.0)
redlock (~> 1.3)

GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
connection_pool (2.4.1)
diff-lcs (1.4.4)
mock_redis (0.29.0)
ruby2_keywords
parallel (1.21.0)
parser (3.0.2.0)
ast (2.4.3)
connection_pool (2.5.3)
diff-lcs (1.6.2)
json (2.13.2)
language_server-protocol (3.17.0.5)
lint_roller (1.1.0)
mock_redis (0.51.0)
redis (~> 5)
parallel (1.27.0)
parser (3.3.9.0)
ast (~> 2.4.1)
rainbow (3.0.0)
rake (13.0.6)
redis (5.0.6)
redis-client (>= 0.9.0)
redis-client (0.14.1)
racc
prism (1.4.0)
racc (1.8.1)
rainbow (3.1.1)
rake (13.3.0)
redis (5.4.1)
redis-client (>= 0.22.0)
redis-client (0.25.1)
connection_pool
redlock (1.3.2)
redis (>= 3.0.0, < 6.0)
regexp_parser (2.1.1)
rexml (3.2.5)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
regexp_parser (2.11.0)
rspec (3.13.1)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.5)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.3)
rubocop (1.23.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.4)
rubocop (1.79.2)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.12.0, < 2.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.46.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.13.0)
parser (>= 3.0.1.1)
rubocop-rspec (2.6.0)
rubocop (~> 1.19)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
unicode-display_width (2.1.0)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.46.0)
parser (>= 3.3.7.2)
prism (~> 1.4)
rubocop-capybara (2.22.1)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-factory_bot (2.27.1)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-rspec (2.31.0)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
rubocop-rspec_rails (~> 2.28)
rubocop-rspec_rails (2.29.1)
rubocop (~> 1.61)
ruby-progressbar (1.13.0)
unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)

PLATFORMS
ruby
Expand All @@ -67,4 +87,4 @@ DEPENDENCIES
rubocop-rspec (~> 2.4)

BUNDLED WITH
2.2.26
2.6.2
12 changes: 7 additions & 5 deletions lib/potlock/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@ def get
end

def set(&block)
value = lock!(&block)
redis.set(key, value)
value
lock! do
value = block.call
redis.set(key, value)
value
end
rescue Redlock::LockError => _e
raise Potlock::LockError
end

private

def lock!(&block)
lock_manager.lock!(lock_key, retry_delay, &block)
def lock!(&)
lock_manager.lock!(lock_key, retry_delay, &)
end

def lock_manager
Expand Down
2 changes: 1 addition & 1 deletion lib/potlock/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Potlock
VERSION = "0.3.0"
VERSION = "0.4.0"
end
8 changes: 1 addition & 7 deletions potlock.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
spec.description = "Potlock is redis based concurrent read-write lock distributed across processes."
spec.homepage = "https://github.com/potloc/potlock"
spec.license = "MIT"
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
spec.required_ruby_version = Gem::Requirement.new(">= 3.4.1")
spec.metadata = {
"allowed_push_host" => "https://rubygems.org",
"changelog_uri" => "#{spec.homepage}/blob/main/CHANGELOG.md",
Expand All @@ -31,10 +31,4 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

spec.add_dependency "redlock", "~> 1.3"

spec.add_development_dependency "mock_redis", "~> 0.2"
spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "rubocop", "~> 1.7"
spec.add_development_dependency "rubocop-rspec", "~> 2.4"
end