with_transactional_lock 2.0.1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -8
- data/Rakefile +5 -2
- data/lib/generators/with_transactional_lock/install/install_generator.rb +3 -1
- data/lib/generators/with_transactional_lock/install/templates/db/migrate/create_transactional_advisory_locks.rb +2 -0
- data/lib/tasks/with_transactional_lock_tasks.rake +2 -0
- data/lib/with_transactional_lock/engine.rb +2 -0
- data/lib/with_transactional_lock/mixin.rb +6 -3
- data/lib/with_transactional_lock/my_sql_helper.rb +2 -0
- data/lib/with_transactional_lock/version.rb +3 -1
- data/lib/with_transactional_lock.rb +3 -3
- metadata +11 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8147bfe089c9fa8afbb4b8752140c15e650d002eb28cc13f57f01ad19b324a1
|
4
|
+
data.tar.gz: b7196af8ba019c67185b62a3362da2e112cccbf8fba68966117b5477f8a8d1c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18e0b1d67b273851c4f31135c2531b72cc1a1ebcf4deed90d2dcae1bcb45ac1e46466932fc0aaa03cbc6d49592a0969c7980f198dd75b7b6db1075c0dd4dc48b
|
7
|
+
data.tar.gz: 13457b7faf99b4ab331d6e1fe494b935323c3793eaac5d503e102729a721b8b76b5a111b7e0c64de42e0d761e27b472381d756e7ce0e477ccd9ad5ee28871021
|
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# with_transactional_lock
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.com/Betterment/with_transactional_lock.svg?token=6b6DErRMUHX47kEoBZ3t&branch=master)](https://travis-ci.com/Betterment/with_transactional_lock)
|
4
|
-
|
5
3
|
A simple extension to ActiveRecord for performing advisory locking on
|
6
4
|
MySQL and PostgreSQL.
|
7
5
|
|
@@ -102,12 +100,6 @@ with the name that you provided. Your block is free to execute its
|
|
102
100
|
critical work. Upon completion of your transaction, the lock will be
|
103
101
|
released.
|
104
102
|
|
105
|
-
### Publishing the gem
|
106
|
-
|
107
|
-
If you make changes to this gem, you will need to publish the changes to a new version on Github Packages, where the private Betterment RubyGems registry is.
|
108
|
-
|
109
|
-
For instructions on how to publish this gem, read this article on ["Publishing Internal Gems" from the Betterment Engineering Wiki](https://betterconfluence.atlassian.net/wiki/spaces/BetterEng/pages/2840952833/Publishing+Internal+Gems).
|
110
|
-
|
111
103
|
## Supported databases
|
112
104
|
|
113
105
|
### PostgreSQL
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
begin
|
2
4
|
require 'bundler/setup'
|
3
5
|
rescue LoadError
|
@@ -30,12 +32,13 @@ if (Rails.env.development? || Rails.env.test?) && defined? Dummy
|
|
30
32
|
|
31
33
|
task(:default).clear
|
32
34
|
if ENV['APPRAISAL_INITIALIZED'] || ENV['CI']
|
35
|
+
tasks = [:spec]
|
33
36
|
tasks += [:rubocop] unless ENV['CI']
|
34
37
|
|
35
|
-
task default: tasks
|
38
|
+
task default: tasks # rubocop:disable Rake/DuplicateTask
|
36
39
|
else
|
37
40
|
require 'appraisal'
|
38
41
|
Appraisal::Task.new
|
39
|
-
task default: :appraisal
|
42
|
+
task default: :appraisal # rubocop:disable Rake/DuplicateTask
|
40
43
|
end
|
41
44
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rails/generators/base'
|
2
4
|
require 'rails/generators/active_record'
|
3
5
|
|
@@ -27,7 +29,7 @@ module WithTransactionalLock
|
|
27
29
|
private
|
28
30
|
|
29
31
|
def mysql?
|
30
|
-
ActiveRecord::Base.connection.adapter_name.downcase
|
32
|
+
ActiveRecord::Base.connection.adapter_name.downcase.include?('mysql')
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_support/concern'
|
2
4
|
|
3
5
|
module WithTransactionalLock
|
@@ -6,8 +8,8 @@ module WithTransactionalLock
|
|
6
8
|
delegate :with_transactional_lock, to: :class
|
7
9
|
|
8
10
|
module ClassMethods
|
9
|
-
def with_transactional_lock(lock_name, &
|
10
|
-
_advisory_lock_class.new(connection, lock_name).yield_with_lock(&
|
11
|
+
def with_transactional_lock(lock_name, &)
|
12
|
+
_advisory_lock_class.new(connection, lock_name).yield_with_lock(&)
|
11
13
|
end
|
12
14
|
|
13
15
|
private
|
@@ -57,7 +59,8 @@ module WithTransactionalLock
|
|
57
59
|
private
|
58
60
|
|
59
61
|
def acquire_lock
|
60
|
-
connection.execute("insert into transactional_advisory_locks values (#{connection.quote(db_lock_name)})
|
62
|
+
connection.execute("insert into transactional_advisory_locks values (#{connection.quote(db_lock_name)}) \
|
63
|
+
on duplicate key update lock_id = lock_id")
|
61
64
|
end
|
62
65
|
end
|
63
66
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "with_transactional_lock/engine"
|
2
4
|
|
3
5
|
module WithTransactionalLock
|
@@ -6,6 +8,4 @@ module WithTransactionalLock
|
|
6
8
|
autoload :MySqlHelper
|
7
9
|
end
|
8
10
|
|
9
|
-
ActiveSupport.on_load
|
10
|
-
ActiveRecord::Base.include WithTransactionalLock::Mixin
|
11
|
-
end
|
11
|
+
ActiveSupport.on_load(:active_record) { include WithTransactionalLock::Mixin }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: with_transactional_lock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Moore
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '7.0'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '7.
|
22
|
+
version: '7.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '7.0'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '7.
|
32
|
+
version: '7.2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: appraisal
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,20 +156,6 @@ dependencies:
|
|
156
156
|
- - "~>"
|
157
157
|
- !ruby/object:Gem::Version
|
158
158
|
version: '3.0'
|
159
|
-
- !ruby/object:Gem::Dependency
|
160
|
-
name: travis
|
161
|
-
requirement: !ruby/object:Gem::Requirement
|
162
|
-
requirements:
|
163
|
-
- - ">="
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version: '0'
|
166
|
-
type: :development
|
167
|
-
prerelease: false
|
168
|
-
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
requirements:
|
170
|
-
- - ">="
|
171
|
-
- !ruby/object:Gem::Version
|
172
|
-
version: '0'
|
173
159
|
description: Advisory locking support for MySQL and Postgresql done right.
|
174
160
|
email:
|
175
161
|
- sam@betterment.com
|
@@ -192,7 +178,9 @@ files:
|
|
192
178
|
homepage: https://github.com/Betterment/with_transactional_lock
|
193
179
|
licenses:
|
194
180
|
- MIT
|
195
|
-
metadata:
|
181
|
+
metadata:
|
182
|
+
allowed_push_host: https://rubygems.org
|
183
|
+
rubygems_mfa_required: 'true'
|
196
184
|
post_install_message:
|
197
185
|
rdoc_options: []
|
198
186
|
require_paths:
|
@@ -201,14 +189,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
201
189
|
requirements:
|
202
190
|
- - ">="
|
203
191
|
- !ruby/object:Gem::Version
|
204
|
-
version: '
|
192
|
+
version: '3.2'
|
205
193
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
194
|
requirements:
|
207
195
|
- - ">="
|
208
196
|
- !ruby/object:Gem::Version
|
209
197
|
version: '0'
|
210
198
|
requirements: []
|
211
|
-
rubygems_version: 3.
|
199
|
+
rubygems_version: 3.5.6
|
212
200
|
signing_key:
|
213
201
|
specification_version: 4
|
214
202
|
summary: Transactional advisory locks for ActiveRecord
|