with_transactional_lock 2.0.1 → 2.3.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/with_transactional_lock/engine.rb +2 -0
- data/lib/with_transactional_lock/mixin.rb +12 -9
- 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 +32 -53
- data/lib/tasks/with_transactional_lock_tasks.rake +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e23e87e0f583421cd8059c2357cb938189754803f981411f6dac9111ba128df
|
4
|
+
data.tar.gz: 7294f251168099acfad4122609c6a0d5b2debb17edb6a66ebc65e5ea87f1efdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e4984a3ea1ceda7c6a163b99eff34f6364ab37038da8a26e15ed01d5527a8775ac70b33db4c6dcbb8a8385528a62bdadb39a2983e05036a269f630a94b72338
|
7
|
+
data.tar.gz: 7f1a85d1c4372eaee6406cb95a8c3c7b45bd35b8ac3248d321c212e06b37f033a4628a4d29ce358d6fcef200e90a671405c9537b3bcf791f0f56f3d787aa5a0b
|
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
|
@@ -21,12 +23,12 @@ module WithTransactionalLock
|
|
21
23
|
def self.locate(connection)
|
22
24
|
adapter = connection.adapter_name.downcase.to_sym
|
23
25
|
case adapter
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
when :mysql, :mysql2
|
27
|
+
MySqlAdvisoryLock
|
28
|
+
when :postgresql
|
29
|
+
PostgresAdvisoryLock
|
30
|
+
else
|
31
|
+
raise "adapter not supported: #{adapter}"
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
@@ -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,65 +1,71 @@
|
|
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.3.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-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
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
|
-
name:
|
34
|
+
name: railties
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "
|
37
|
+
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
40
|
-
|
39
|
+
version: '7.0'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '7.2'
|
43
|
+
type: :runtime
|
41
44
|
prerelease: false
|
42
45
|
version_requirements: !ruby/object:Gem::Requirement
|
43
46
|
requirements:
|
44
|
-
- - "
|
47
|
+
- - ">="
|
45
48
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
49
|
+
version: '7.0'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '7.2'
|
47
53
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
54
|
+
name: appraisal
|
49
55
|
requirement: !ruby/object:Gem::Requirement
|
50
56
|
requirements:
|
51
|
-
- - "
|
57
|
+
- - "~>"
|
52
58
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
59
|
+
version: 2.2.0
|
54
60
|
type: :development
|
55
61
|
prerelease: false
|
56
62
|
version_requirements: !ruby/object:Gem::Requirement
|
57
63
|
requirements:
|
58
|
-
- - "
|
64
|
+
- - "~>"
|
59
65
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
66
|
+
version: 2.2.0
|
61
67
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
68
|
+
name: betterlint
|
63
69
|
requirement: !ruby/object:Gem::Requirement
|
64
70
|
requirements:
|
65
71
|
- - ">="
|
@@ -73,7 +79,7 @@ dependencies:
|
|
73
79
|
- !ruby/object:Gem::Version
|
74
80
|
version: '0'
|
75
81
|
- !ruby/object:Gem::Dependency
|
76
|
-
name:
|
82
|
+
name: database_cleaner
|
77
83
|
requirement: !ruby/object:Gem::Requirement
|
78
84
|
requirements:
|
79
85
|
- - ">="
|
@@ -116,20 +122,6 @@ dependencies:
|
|
116
122
|
version: '0'
|
117
123
|
- !ruby/object:Gem::Dependency
|
118
124
|
name: rspec-rails
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
120
|
-
requirements:
|
121
|
-
- - "~>"
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: '3.1'
|
124
|
-
type: :development
|
125
|
-
prerelease: false
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
127
|
-
requirements:
|
128
|
-
- - "~>"
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
version: '3.1'
|
131
|
-
- !ruby/object:Gem::Dependency
|
132
|
-
name: rspec-retry
|
133
125
|
requirement: !ruby/object:Gem::Requirement
|
134
126
|
requirements:
|
135
127
|
- - ">="
|
@@ -143,21 +135,7 @@ dependencies:
|
|
143
135
|
- !ruby/object:Gem::Version
|
144
136
|
version: '0'
|
145
137
|
- !ruby/object:Gem::Dependency
|
146
|
-
name:
|
147
|
-
requirement: !ruby/object:Gem::Requirement
|
148
|
-
requirements:
|
149
|
-
- - "~>"
|
150
|
-
- !ruby/object:Gem::Version
|
151
|
-
version: '3.0'
|
152
|
-
type: :development
|
153
|
-
prerelease: false
|
154
|
-
version_requirements: !ruby/object:Gem::Requirement
|
155
|
-
requirements:
|
156
|
-
- - "~>"
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
version: '3.0'
|
159
|
-
- !ruby/object:Gem::Dependency
|
160
|
-
name: travis
|
138
|
+
name: rspec-retry
|
161
139
|
requirement: !ruby/object:Gem::Requirement
|
162
140
|
requirements:
|
163
141
|
- - ">="
|
@@ -183,7 +161,6 @@ files:
|
|
183
161
|
- lib/generators/with_transactional_lock/install/install_generator.rb
|
184
162
|
- lib/generators/with_transactional_lock/install/templates/README
|
185
163
|
- lib/generators/with_transactional_lock/install/templates/db/migrate/create_transactional_advisory_locks.rb
|
186
|
-
- lib/tasks/with_transactional_lock_tasks.rake
|
187
164
|
- lib/with_transactional_lock.rb
|
188
165
|
- lib/with_transactional_lock/engine.rb
|
189
166
|
- lib/with_transactional_lock/mixin.rb
|
@@ -192,7 +169,9 @@ files:
|
|
192
169
|
homepage: https://github.com/Betterment/with_transactional_lock
|
193
170
|
licenses:
|
194
171
|
- MIT
|
195
|
-
metadata:
|
172
|
+
metadata:
|
173
|
+
allowed_push_host: https://rubygems.org
|
174
|
+
rubygems_mfa_required: 'true'
|
196
175
|
post_install_message:
|
197
176
|
rdoc_options: []
|
198
177
|
require_paths:
|
@@ -201,14 +180,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
201
180
|
requirements:
|
202
181
|
- - ">="
|
203
182
|
- !ruby/object:Gem::Version
|
204
|
-
version: '
|
183
|
+
version: '3.2'
|
205
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
185
|
requirements:
|
207
186
|
- - ">="
|
208
187
|
- !ruby/object:Gem::Version
|
209
188
|
version: '0'
|
210
189
|
requirements: []
|
211
|
-
rubygems_version: 3.
|
190
|
+
rubygems_version: 3.5.23
|
212
191
|
signing_key:
|
213
192
|
specification_version: 4
|
214
193
|
summary: Transactional advisory locks for ActiveRecord
|