coil 1.5.3 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/coil/queue_locking.rb +7 -7
- data/lib/coil/version.rb +1 -1
- data/lib/coil.rb +1 -0
- data/rbi/coil.rbi +10 -12
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfa810214fb7a098acf7a2dbdfa046eae675d4946e2d6e8e95b15e90b9e7e094
|
4
|
+
data.tar.gz: 3b10e3bd7c79f6ca4dc5d9b4bfbfa8c7ab0704b463fa09802188b3615802560b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2695c8998551d16899c3d4e5dd1ea4838a38737a13a6fc4da3a46ec725d15df5333cec27064f40077282cf8f5bc59425adc3cecd63804e3f09446ad9209d5fa2
|
7
|
+
data.tar.gz: 448f9223a90d0026e2bb7e1f79ae92f05c2d542b57c40e95e4657f806920fe0d25b6ae308d9fc915e9ff183341e281ab251a4f9ab4219ee7beb6f9ff3f9d6c40
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
## main
|
2
2
|
|
3
|
+
## [1.5.4](https://github.com/OdekoTeam/coil/compare/1.5.3...1.5.4) (2025-03-24)
|
4
|
+
#### Added
|
5
|
+
- Rails 7.2 support ([be1cdc4](https://github.com/OdekoTeam/coil/commit/be1cdc4bde1fb73d1ac24f3b786a1d58a748d87f))
|
6
|
+
|
3
7
|
## [1.5.3](https://github.com/OdekoTeam/coil/compare/1.5.2...1.5.3) (2025-03-24)
|
4
8
|
#### Added
|
5
9
|
- Ruby 3.2 and 3.3 support ([a4ceb7c](https://github.com/OdekoTeam/coil/commit/a4ceb7cf2cefc47ae3c14a876a0782aaec0e5c43))
|
data/lib/coil/queue_locking.rb
CHANGED
@@ -60,8 +60,9 @@ module Coil
|
|
60
60
|
ks = keys.uniq(&:int64).sort_by(&:int64).reverse
|
61
61
|
|
62
62
|
fn = ks.reduce(blk) do |f, key|
|
63
|
-
-> do
|
64
|
-
|
63
|
+
->(*args) do
|
64
|
+
lock(key:, wait:)
|
65
|
+
f.call(*args)
|
65
66
|
end
|
66
67
|
end
|
67
68
|
|
@@ -70,22 +71,21 @@ module Coil
|
|
70
71
|
|
71
72
|
private
|
72
73
|
|
73
|
-
def
|
74
|
-
wait ?
|
75
|
-
blk.call
|
74
|
+
def lock(key:, wait:)
|
75
|
+
wait ? acquire_lock(key:) : try_acquire_lock(key:)
|
76
76
|
end
|
77
77
|
|
78
78
|
ACQUIRE_LOCK = "pg_advisory_xact_lock"
|
79
79
|
TRY_ACQUIRE_LOCK = "pg_try_advisory_xact_lock"
|
80
80
|
|
81
|
-
def
|
81
|
+
def acquire_lock(key:)
|
82
82
|
command = sql(fn: ACQUIRE_LOCK, key:)
|
83
83
|
connection.execute(command)
|
84
84
|
rescue ActiveRecord::LockWaitTimeout
|
85
85
|
raise LockWaitTimeout
|
86
86
|
end
|
87
87
|
|
88
|
-
def
|
88
|
+
def try_acquire_lock(key:)
|
89
89
|
query = sql(fn: TRY_ACQUIRE_LOCK, key:)
|
90
90
|
return if connection.select_value(query)
|
91
91
|
raise LockWaitTimeout
|
data/lib/coil/version.rb
CHANGED
data/lib/coil.rb
CHANGED
data/rbi/coil.rbi
CHANGED
@@ -187,7 +187,12 @@ module Coil::QueueLocking
|
|
187
187
|
message_type: String,
|
188
188
|
message_keys: T::Array[T.untyped],
|
189
189
|
wait: T::Boolean,
|
190
|
-
blk: T.
|
190
|
+
blk: T.any(
|
191
|
+
# ActiveRecord versions 7.2 and newer yield a transaction as the block arg.
|
192
|
+
T.proc.params(arg0: ActiveRecord::Transaction).returns(T.type_parameter(:P)),
|
193
|
+
# Earlier versions yield to the block with no args.
|
194
|
+
T.proc.returns(T.type_parameter(:P))
|
195
|
+
)
|
191
196
|
).returns(T.type_parameter(:P))
|
192
197
|
end
|
193
198
|
def locking(queue_type:, message_type:, message_keys:, wait: T.unsafe(nil), &blk); end
|
@@ -198,23 +203,16 @@ module Coil::QueueLocking
|
|
198
203
|
def connection; end
|
199
204
|
|
200
205
|
sig { params(key: Key).void }
|
201
|
-
def
|
206
|
+
def acquire_lock(key:); end
|
202
207
|
|
203
208
|
sig { params(fn: String, key: Key).returns(String) }
|
204
209
|
def sql(fn:, key:); end
|
205
210
|
|
206
211
|
sig { params(key: Key).void }
|
207
|
-
def
|
212
|
+
def try_acquire_lock(key:); end
|
208
213
|
|
209
|
-
sig
|
210
|
-
|
211
|
-
.params(
|
212
|
-
key: Key,
|
213
|
-
wait: T::Boolean,
|
214
|
-
blk: T.proc.returns(T.type_parameter(:P))
|
215
|
-
).returns(T.type_parameter(:P))
|
216
|
-
end
|
217
|
-
def with_lock(key:, wait:, &blk); end
|
214
|
+
sig { params(key: Key, wait: T::Boolean).void }
|
215
|
+
def lock(key:, wait:); end
|
218
216
|
end
|
219
217
|
|
220
218
|
Coil::QueueLocking::ACQUIRE_LOCK = T.let(T.unsafe(nil), String)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Brennan
|
@@ -75,9 +75,9 @@ dependencies:
|
|
75
75
|
name: rails
|
76
76
|
requirement: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
|
-
- - "
|
78
|
+
- - "~>"
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version:
|
80
|
+
version: 7.2.2
|
81
81
|
- - "<"
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '8.0'
|
@@ -85,9 +85,9 @@ dependencies:
|
|
85
85
|
prerelease: false
|
86
86
|
version_requirements: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- - "
|
88
|
+
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
90
|
+
version: 7.2.2
|
91
91
|
- - "<"
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '8.0'
|