redis_queued_locks 1.23.1 → 1.24.0
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/.claude/project-overview.md +70 -33
- data/.claude/rules/acquirer.md +6 -4
- data/.claude/rules/arguments.md +2 -2
- data/.claude/rules/git.md +1 -1
- data/.claude/rules/logic.md +5 -4
- data/.claude/rules/readme.md +40 -0
- data/.claude/rules/swarm.md +2 -2
- data/.claude/rules/tests.md +3 -2
- data/.claude/rules/type-checking.md +3 -2
- data/.claude/rules/visitors.md +3 -2
- data/.claude/skills/rql-code-review/SKILL.md +6 -3
- data/.claude/skills/rql-project-full-review/SKILL.md +171 -0
- data/.claude/skills/rql-project-full-review/templates/report.en.md +41 -0
- data/.claude/skills/rql-project-full-review/templates/report.ru.md +41 -0
- data/CHANGELOG.md +25 -10
- data/CLAUDE.md +7 -5
- data/README.md +381 -13
- data/lib/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rb +60 -1
- data/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rb +38 -1
- data/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rb +31 -4
- data/lib/redis_queued_locks/acquirer/acquire_lock/with_acq_timeout.rb +6 -3
- data/lib/redis_queued_locks/acquirer/acquire_lock/yield_expire.rb +243 -35
- data/lib/redis_queued_locks/acquirer/acquire_lock.rb +93 -3
- data/lib/redis_queued_locks/acquirer/lock_series/try_to_lock_series.rb +27 -1
- data/lib/redis_queued_locks/acquirer/lock_series.rb +150 -14
- data/lib/redis_queued_locks/client.rb +96 -16
- data/lib/redis_queued_locks/config/dsl.rb +2 -0
- data/lib/redis_queued_locks/config.rb +35 -11
- data/lib/redis_queued_locks/errors.rb +11 -2
- data/lib/redis_queued_locks/lock_keeper/instr_visitor.rb +173 -0
- data/lib/redis_queued_locks/lock_keeper/lease.rb +434 -0
- data/lib/redis_queued_locks/lock_keeper/lock_lease.rb +106 -0
- data/lib/redis_queued_locks/lock_keeper/log_visitor.rb +187 -0
- data/lib/redis_queued_locks/lock_keeper.rb +1007 -0
- data/lib/redis_queued_locks/resource.rb +1 -1
- data/lib/redis_queued_locks/swarm/swarm_element/threaded.rb +2 -2
- data/lib/redis_queued_locks/utilities.rb +1 -15
- data/lib/redis_queued_locks/version.rb +2 -2
- data/lib/redis_queued_locks.rb +1 -0
- data/sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rbs +14 -0
- data/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rbs +12 -0
- data/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rbs +2 -0
- data/sig/redis_queued_locks/acquirer/acquire_lock/yield_expire.rbs +30 -2
- data/sig/redis_queued_locks/acquirer/acquire_lock.rbs +6 -1
- data/sig/redis_queued_locks/acquirer/lock_series.rbs +12 -1
- data/sig/redis_queued_locks/client.rbs +14 -0
- data/sig/redis_queued_locks/config.rbs +15 -1
- data/sig/redis_queued_locks/errors.rbs +6 -0
- data/sig/redis_queued_locks/instrument/void_notifier.rbs +2 -2
- data/sig/redis_queued_locks/lock_keeper/instr_visitor.rbs +67 -0
- data/sig/redis_queued_locks/lock_keeper/lease.rbs +78 -0
- data/sig/redis_queued_locks/lock_keeper/lock_lease.rbs +19 -0
- data/sig/redis_queued_locks/lock_keeper/log_visitor.rbs +62 -0
- data/sig/redis_queued_locks/lock_keeper.rbs +108 -0
- data/sig/redis_queued_locks/utilities.rbs +0 -2
- data/sig/vendor/redis_client.rbs +1 -0
- metadata +15 -1
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# @api private
|
|
4
|
+
# @since 1.24.0
|
|
5
|
+
# rubocop:disable Metrics/ModuleLength
|
|
6
|
+
module RedisQueuedLocks::LockKeeper::LogVisitor
|
|
7
|
+
# rubocop:disable Metrics/ClassLength
|
|
8
|
+
class << self
|
|
9
|
+
# @param logger [::Logger,#debug]
|
|
10
|
+
# @param log_sampled [Boolean]
|
|
11
|
+
# @param lock_key [String]
|
|
12
|
+
# @param rw_mode [Symbol]
|
|
13
|
+
# @param ext_ttl [Integer]
|
|
14
|
+
# @param rem_ttl [Integer]
|
|
15
|
+
# @param acquirer_id [String]
|
|
16
|
+
# @param host_id [String]
|
|
17
|
+
# @return [void]
|
|
18
|
+
#
|
|
19
|
+
# @api private
|
|
20
|
+
# @since 1.24.0
|
|
21
|
+
def lock_auto_extended(
|
|
22
|
+
logger,
|
|
23
|
+
log_sampled,
|
|
24
|
+
lock_key,
|
|
25
|
+
rw_mode,
|
|
26
|
+
ext_ttl,
|
|
27
|
+
rem_ttl,
|
|
28
|
+
acquirer_id,
|
|
29
|
+
host_id
|
|
30
|
+
)
|
|
31
|
+
return unless log_sampled
|
|
32
|
+
|
|
33
|
+
logger.debug do
|
|
34
|
+
"[redis_queued_locks.lock_auto_extended] " \
|
|
35
|
+
"lock_key => '#{lock_key}' " \
|
|
36
|
+
"rw_mode => '#{rw_mode}' " \
|
|
37
|
+
"ext_ttl => #{ext_ttl} " \
|
|
38
|
+
"rem_ttl => #{rem_ttl} " \
|
|
39
|
+
"acq_id => '#{acquirer_id}' " \
|
|
40
|
+
"hst_id => '#{host_id}'"
|
|
41
|
+
end rescue nil
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# @param logger [::Logger,#debug]
|
|
45
|
+
# @param log_sampled [Boolean]
|
|
46
|
+
# @param lock_key [String]
|
|
47
|
+
# @param rw_mode [Symbol]
|
|
48
|
+
# @param ext_ttl [Integer]
|
|
49
|
+
# @param acquirer_id [String]
|
|
50
|
+
# @param host_id [String]
|
|
51
|
+
# @param error [String] The class name of the error.
|
|
52
|
+
# @return [void]
|
|
53
|
+
#
|
|
54
|
+
# @api private
|
|
55
|
+
# @since 1.24.0
|
|
56
|
+
def lock_auto_extension_failed(
|
|
57
|
+
logger,
|
|
58
|
+
log_sampled,
|
|
59
|
+
lock_key,
|
|
60
|
+
rw_mode,
|
|
61
|
+
ext_ttl,
|
|
62
|
+
acquirer_id,
|
|
63
|
+
host_id,
|
|
64
|
+
error
|
|
65
|
+
)
|
|
66
|
+
return unless log_sampled
|
|
67
|
+
|
|
68
|
+
logger.debug do
|
|
69
|
+
"[redis_queued_locks.lock_auto_extension_failed] " \
|
|
70
|
+
"lock_key => '#{lock_key}' " \
|
|
71
|
+
"rw_mode => '#{rw_mode}' " \
|
|
72
|
+
"ext_ttl => #{ext_ttl} " \
|
|
73
|
+
"acq_id => '#{acquirer_id}' " \
|
|
74
|
+
"hst_id => '#{host_id}' " \
|
|
75
|
+
"error => '#{error}'"
|
|
76
|
+
end rescue nil
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# @param logger [::Logger,#debug]
|
|
80
|
+
# @param log_sampled [Boolean]
|
|
81
|
+
# @param lock_key [String]
|
|
82
|
+
# @param rw_mode [Symbol]
|
|
83
|
+
# @param acquirer_id [String]
|
|
84
|
+
# @param host_id [String]
|
|
85
|
+
# @param hold_time [Integer]
|
|
86
|
+
# @return [void]
|
|
87
|
+
#
|
|
88
|
+
# @api private
|
|
89
|
+
# @since 1.24.0
|
|
90
|
+
def auto_extended_lock_lost(
|
|
91
|
+
logger,
|
|
92
|
+
log_sampled,
|
|
93
|
+
lock_key,
|
|
94
|
+
rw_mode,
|
|
95
|
+
acquirer_id,
|
|
96
|
+
host_id,
|
|
97
|
+
hold_time
|
|
98
|
+
)
|
|
99
|
+
return unless log_sampled
|
|
100
|
+
|
|
101
|
+
logger.debug do
|
|
102
|
+
"[redis_queued_locks.auto_extended_lock_lost] " \
|
|
103
|
+
"lock_key => '#{lock_key}' " \
|
|
104
|
+
"rw_mode => '#{rw_mode}' " \
|
|
105
|
+
"acq_id => '#{acquirer_id}' " \
|
|
106
|
+
"hst_id => '#{host_id}' " \
|
|
107
|
+
"hold_time => #{hold_time}"
|
|
108
|
+
end rescue nil
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# @param logger [::Logger,#debug]
|
|
112
|
+
# @param log_sampled [Boolean]
|
|
113
|
+
# @param lock_key [String]
|
|
114
|
+
# @param rw_mode [Symbol]
|
|
115
|
+
# @param max_hold_time_during_auto_extend [Integer]
|
|
116
|
+
# @param acquirer_id [String]
|
|
117
|
+
# @param host_id [String]
|
|
118
|
+
# @return [void]
|
|
119
|
+
#
|
|
120
|
+
# @api private
|
|
121
|
+
# @since 1.24.0
|
|
122
|
+
def lock_hold_limit_reached(
|
|
123
|
+
logger,
|
|
124
|
+
log_sampled,
|
|
125
|
+
lock_key,
|
|
126
|
+
rw_mode,
|
|
127
|
+
max_hold_time_during_auto_extend,
|
|
128
|
+
acquirer_id,
|
|
129
|
+
host_id
|
|
130
|
+
)
|
|
131
|
+
return unless log_sampled
|
|
132
|
+
|
|
133
|
+
logger.debug do
|
|
134
|
+
"[redis_queued_locks.lock_hold_limit_reached] " \
|
|
135
|
+
"lock_key => '#{lock_key}' " \
|
|
136
|
+
"rw_mode => '#{rw_mode}' " \
|
|
137
|
+
"max_hold_time_during_auto_extend => #{max_hold_time_during_auto_extend} " \
|
|
138
|
+
"acq_id => '#{acquirer_id}' " \
|
|
139
|
+
"hst_id => '#{host_id}'"
|
|
140
|
+
end rescue nil
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# @param logger [::Logger,#debug]
|
|
144
|
+
# @param log_sampled [Boolean]
|
|
145
|
+
# @param lock_key [String]
|
|
146
|
+
# @param rw_mode [Symbol]
|
|
147
|
+
# @param hold_time [Integer]
|
|
148
|
+
# The requested time (`RedisQueuedLocks::LockKeeper::LockLease#hold_for`).
|
|
149
|
+
# @param rem_hold_time [Integer,NilClass] The time left till the hold limit, `nil`: no limit.
|
|
150
|
+
# @param ext_ttl [Integer]
|
|
151
|
+
# @param rem_ttl [Integer]
|
|
152
|
+
# @param acquirer_id [String]
|
|
153
|
+
# @param host_id [String]
|
|
154
|
+
# @return [void]
|
|
155
|
+
#
|
|
156
|
+
# @api private
|
|
157
|
+
# @since 1.24.0
|
|
158
|
+
def lock_hold_limit_extended(
|
|
159
|
+
logger,
|
|
160
|
+
log_sampled,
|
|
161
|
+
lock_key,
|
|
162
|
+
rw_mode,
|
|
163
|
+
hold_time,
|
|
164
|
+
rem_hold_time,
|
|
165
|
+
ext_ttl,
|
|
166
|
+
rem_ttl,
|
|
167
|
+
acquirer_id,
|
|
168
|
+
host_id
|
|
169
|
+
)
|
|
170
|
+
return unless log_sampled
|
|
171
|
+
|
|
172
|
+
logger.debug do
|
|
173
|
+
"[redis_queued_locks.lock_hold_limit_extended] " \
|
|
174
|
+
"lock_key => '#{lock_key}' " \
|
|
175
|
+
"rw_mode => '#{rw_mode}' " \
|
|
176
|
+
"hold_time => #{hold_time} " \
|
|
177
|
+
"rem_hold_time => #{rem_hold_time.inspect} " \
|
|
178
|
+
"ext_ttl => #{ext_ttl} " \
|
|
179
|
+
"rem_ttl => #{rem_ttl} " \
|
|
180
|
+
"acq_id => '#{acquirer_id}' " \
|
|
181
|
+
"hst_id => '#{host_id}'"
|
|
182
|
+
end rescue nil
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
# rubocop:enable Metrics/ClassLength
|
|
186
|
+
end
|
|
187
|
+
# rubocop:enable Metrics/ModuleLength
|