redis_queued_locks 1.17.0 → 1.18.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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.claude/project-overview.md +86 -10
  3. data/.claude/rules/acquirer.md +31 -11
  4. data/.claude/rules/arguments.md +2 -1
  5. data/.claude/rules/git.md +46 -0
  6. data/.claude/rules/logic.md +9 -3
  7. data/.claude/rules/swarm.md +4 -3
  8. data/.claude/rules/tests.md +9 -3
  9. data/.claude/rules/type-checking.md +10 -2
  10. data/.claude/rules/visitors.md +12 -7
  11. data/CHANGELOG.md +62 -0
  12. data/CLAUDE.md +7 -2
  13. data/README.md +348 -79
  14. data/lib/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue/log_visitor.rb +6 -3
  15. data/lib/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rb +9 -7
  16. data/lib/redis_queued_locks/acquirer/acquire_lock/instr_visitor.rb +20 -10
  17. data/lib/redis_queued_locks/acquirer/acquire_lock/log_visitor.rb +34 -16
  18. data/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rb +240 -28
  19. data/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rb +398 -129
  20. data/lib/redis_queued_locks/acquirer/acquire_lock/yield_expire/log_visitor.rb +12 -6
  21. data/lib/redis_queued_locks/acquirer/acquire_lock/yield_expire.rb +32 -8
  22. data/lib/redis_queued_locks/acquirer/acquire_lock.rb +73 -20
  23. data/lib/redis_queued_locks/acquirer/clear_dead_requests.rb +9 -1
  24. data/lib/redis_queued_locks/acquirer/extend_lock_ttl.rb +182 -3
  25. data/lib/redis_queued_locks/acquirer/is_locked.rb +19 -2
  26. data/lib/redis_queued_locks/acquirer/is_queued.rb +6 -2
  27. data/lib/redis_queued_locks/acquirer/lock_info.rb +96 -6
  28. data/lib/redis_queued_locks/acquirer/lock_series_poc/instr_visitor.rb +8 -2
  29. data/lib/redis_queued_locks/acquirer/lock_series_poc/log_visitor.rb +18 -6
  30. data/lib/redis_queued_locks/acquirer/lock_series_poc.rb +126 -27
  31. data/lib/redis_queued_locks/acquirer/locks.rb +103 -6
  32. data/lib/redis_queued_locks/acquirer/queue_info.rb +38 -9
  33. data/lib/redis_queued_locks/acquirer/queues.rb +28 -4
  34. data/lib/redis_queued_locks/acquirer/release_all_locks.rb +35 -1
  35. data/lib/redis_queued_locks/acquirer/release_lock.rb +40 -9
  36. data/lib/redis_queued_locks/acquirer/release_locks_of.rb +43 -3
  37. data/lib/redis_queued_locks/acquirer/release_read_lock.rb +143 -0
  38. data/lib/redis_queued_locks/acquirer.rb +1 -0
  39. data/lib/redis_queued_locks/client.rb +129 -14
  40. data/lib/redis_queued_locks/resource.rb +117 -9
  41. data/lib/redis_queued_locks/swarm/flush_zombies.rb +38 -0
  42. data/lib/redis_queued_locks/swarm/zombie_info.rb +42 -0
  43. data/lib/redis_queued_locks/version.rb +1 -1
  44. data/rbs_collection.lock.yaml +10 -2
  45. data/rbs_collection.yaml +0 -2
  46. data/sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue/log_visitor.rbs +2 -1
  47. data/sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rbs +0 -1
  48. data/sig/redis_queued_locks/acquirer/acquire_lock/instr_visitor.rbs +5 -0
  49. data/sig/redis_queued_locks/acquirer/acquire_lock/log_visitor.rbs +12 -6
  50. data/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rbs +74 -7
  51. data/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rbs +4 -2
  52. data/sig/redis_queued_locks/acquirer/acquire_lock/yield_expire.rbs +3 -0
  53. data/sig/redis_queued_locks/acquirer/acquire_lock/yield_with_expire/log_visitor.rbs +4 -2
  54. data/sig/redis_queued_locks/acquirer/extend_lock_ttl.rbs +19 -1
  55. data/sig/redis_queued_locks/acquirer/lock_info.rbs +9 -1
  56. data/sig/redis_queued_locks/acquirer/locks.rbs +10 -1
  57. data/sig/redis_queued_locks/acquirer/queue_info.rbs +2 -4
  58. data/sig/redis_queued_locks/acquirer/queues.rbs +1 -1
  59. data/sig/redis_queued_locks/acquirer/release_lock.rbs +8 -1
  60. data/sig/redis_queued_locks/acquirer/release_read_lock.rbs +44 -0
  61. data/sig/redis_queued_locks/client.rbs +22 -2
  62. data/sig/redis_queued_locks/resource.rbs +9 -2
  63. data/sig/redis_queued_locks/swarm/zombie_info.rbs +5 -0
  64. metadata +4 -1
@@ -83,6 +83,7 @@ module RedisQueuedLocks::Swarm::ZombieInfo
83
83
  #
84
84
  # @api private
85
85
  # @since 1.9.0
86
+ # @version 1.18.0
86
87
  def extract_zombie_locks(rconn, zombie_ttl, lock_scan_size)
87
88
  zombie_hosts = extract_zombie_hosts(rconn, zombie_ttl)
88
89
  zombie_locks = Set.new
@@ -92,6 +93,10 @@ module RedisQueuedLocks::Swarm::ZombieInfo
92
93
  _acquirer_id, host_id = rconn.call('HMGET', lock_key, 'acq_id', 'hst_id')
93
94
  zombie_locks << lock_key if zombie_hosts.include?(host_id)
94
95
  end
96
+ # NOTE: (RW) readers registries with zombie read locks
97
+ each_zombie_read_lock(rconn, zombie_hosts, lock_scan_size) do |lock_readers_key, _acquirer_id|
98
+ zombie_locks << lock_readers_key
99
+ end
95
100
  zombie_locks
96
101
  end
97
102
 
@@ -102,6 +107,7 @@ module RedisQueuedLocks::Swarm::ZombieInfo
102
107
  #
103
108
  # @api private
104
109
  # @since 1.9.0
110
+ # @version 1.18.0
105
111
  def extract_zombie_acquirers(rconn, zombie_ttl, lock_scan_size)
106
112
  zombie_hosts = extract_zombie_hosts(rconn, zombie_ttl)
107
113
  zombie_acquirers = Set.new
@@ -111,6 +117,10 @@ module RedisQueuedLocks::Swarm::ZombieInfo
111
117
  acquirer_id, host_id = rconn.call('HMGET', lock_key, 'acq_id', 'hst_id')
112
118
  zombie_acquirers << acquirer_id if zombie_hosts.include?(host_id)
113
119
  end
120
+ # NOTE: (RW) zombie read lock acquirers
121
+ each_zombie_read_lock(rconn, zombie_hosts, lock_scan_size) do |_lock_readers_key, acquirer_id|
122
+ zombie_acquirers << acquirer_id
123
+ end
114
124
  zombie_acquirers
115
125
  end
116
126
 
@@ -126,6 +136,7 @@ module RedisQueuedLocks::Swarm::ZombieInfo
126
136
  #
127
137
  # @api private
128
138
  # @since 1.9.0
139
+ # @version 1.18.0
129
140
  def extract_all(rconn, zombie_ttl, lock_scan_size)
130
141
  zombie_hosts = extract_zombie_hosts(rconn, zombie_ttl)
131
142
  zombie_locks = Set.new
@@ -139,7 +150,38 @@ module RedisQueuedLocks::Swarm::ZombieInfo
139
150
  zombie_locks << lock_key
140
151
  end
141
152
  end
153
+ # NOTE: (RW) zombie read locks
154
+ each_zombie_read_lock(rconn, zombie_hosts, lock_scan_size) do |lock_readers_key, acquirer_id|
155
+ zombie_acquirers << acquirer_id
156
+ zombie_locks << lock_readers_key
157
+ end
142
158
  { zombie_hosts:, zombie_acquirers:, zombie_locks: }
143
159
  end
160
+
161
+ # Iterates over read locks of zombie hosts
162
+ # (read locks store acquirer ids only: the host is a part of the acquirer id).
163
+ #
164
+ # @param rconn [RedisClient] redis connection obtained via `#with` from RedisClient instance;
165
+ # @param zombie_hosts [Set<String>]
166
+ # @param lock_scan_size [Integer]
167
+ # @yield [lock_readers_key, acquirer_id]
168
+ # @yieldparam lock_readers_key [String] Readers registry with a zombie read lock.
169
+ # @yieldparam acquirer_id [String] Zombie read lock acquirer.
170
+ # @return [void]
171
+ #
172
+ # @api private
173
+ # @since 1.18.0
174
+ def each_zombie_read_lock(rconn, zombie_hosts, lock_scan_size)
175
+ rconn.scan(
176
+ 'MATCH', RedisQueuedLocks::Resource::LOCK_READERS_PATTERN, count: lock_scan_size
177
+ ) do |lock_readers_key|
178
+ # @type var read_lock_acquirers: Array[String]
179
+ read_lock_acquirers = rconn.call('ZRANGE', lock_readers_key, '0', '-1')
180
+ read_lock_acquirers.each do |acquirer_id|
181
+ host_id = RedisQueuedLocks::Resource.host_identifier_from_acquirer(acquirer_id)
182
+ yield(lock_readers_key, acquirer_id) if zombie_hosts.include?(host_id)
183
+ end
184
+ end
185
+ end
144
186
  end
145
187
  end
@@ -6,5 +6,5 @@ module RedisQueuedLocks
6
6
  # @api public
7
7
  # @since 0.0.1
8
8
  # @version 1.17.0
9
- VERSION = '1.17.0'
9
+ VERSION = '1.18.0'
10
10
  end
@@ -6,14 +6,22 @@ gems:
6
6
  source:
7
7
  type: git
8
8
  name: ruby/gem_rbs_collection
9
- revision: 52a7ef8a9328fb2413e3b42dd8ee37deb703a940
9
+ revision: c69c75ba79d7c19870f8d0e6fa7fe2c1d356e5ae
10
10
  remote: https://github.com/ruby/gem_rbs_collection.git
11
11
  repo_dir: gems
12
12
  - name: logger
13
+ version: '1.7'
14
+ source:
15
+ type: git
16
+ name: ruby/gem_rbs_collection
17
+ revision: c69c75ba79d7c19870f8d0e6fa7fe2c1d356e5ae
18
+ remote: https://github.com/ruby/gem_rbs_collection.git
19
+ repo_dir: gems
20
+ - name: monitor
13
21
  version: '0'
14
22
  source:
15
23
  type: stdlib
16
- - name: monitor
24
+ - name: random-formatter
17
25
  version: '0'
18
26
  source:
19
27
  type: stdlib
data/rbs_collection.yaml CHANGED
@@ -11,7 +11,5 @@ gems:
11
11
  - name: redis-client
12
12
  - name: securerandom
13
13
  - name: timeout
14
- - name: redis-client
15
- - name: securerandom
16
14
  - name: logger
17
15
  - name: monitor
@@ -12,7 +12,8 @@ module RedisQueuedLocks
12
12
  Integer queue_ttl,
13
13
  String acquirer_id,
14
14
  String host_id,
15
- Symbol access_strategy
15
+ Symbol access_strategy,
16
+ Symbol rw_mode
16
17
  ) -> void
17
18
  end
18
19
  end
@@ -12,7 +12,6 @@ module RedisQueuedLocks
12
12
  Symbol read_write_mode,
13
13
  String lock_key_queue,
14
14
  String read_lock_key_queue,
15
- String write_lock_key_queue,
16
15
  Integer queue_ttl,
17
16
  String acquirer_id,
18
17
  String host_id,
@@ -8,6 +8,7 @@ module RedisQueuedLocks
8
8
  RQL::instrObj instrumenter,
9
9
  bool instr_sampled,
10
10
  String lock_key,
11
+ Symbol rw_mode,
11
12
  Integer? ttl,
12
13
  String acq_id,
13
14
  String hst_id,
@@ -20,6 +21,7 @@ module RedisQueuedLocks
20
21
  RQL::instrObj instrumenter,
21
22
  bool instr_sampled,
22
23
  String lock_key,
24
+ Symbol rw_mode,
23
25
  Integer? ttl,
24
26
  String acq_id,
25
27
  String hst_id,
@@ -32,6 +34,7 @@ module RedisQueuedLocks
32
34
  RQL::instrObj instrumenter,
33
35
  bool instr_sampled,
34
36
  String lock_key,
37
+ Symbol rw_mode,
35
38
  Integer? ttl,
36
39
  String acq_id,
37
40
  String hst_id,
@@ -44,6 +47,7 @@ module RedisQueuedLocks
44
47
  RQL::instrObj instrumenter,
45
48
  bool instr_sampled,
46
49
  String lock_key,
50
+ Symbol rw_mode,
47
51
  Integer? ttl,
48
52
  String acq_id,
49
53
  String hst_id,
@@ -57,6 +61,7 @@ module RedisQueuedLocks
57
61
  RQL::instrObj instrumenter,
58
62
  bool instr_sampled,
59
63
  String lock_key,
64
+ Symbol rw_mode,
60
65
  Integer? ttl,
61
66
  String acq_id,
62
67
  String hst_id,
@@ -11,7 +11,8 @@ module RedisQueuedLocks
11
11
  Integer queue_ttl,
12
12
  String acquirer_id,
13
13
  String host_id,
14
- Symbol access_strategy
14
+ Symbol access_strategy,
15
+ Symbol rw_mode
15
16
  ) -> void
16
17
 
17
18
  def self.start_try_to_lock_cycle: (
@@ -21,7 +22,8 @@ module RedisQueuedLocks
21
22
  Integer queue_ttl,
22
23
  String acquirer_id,
23
24
  String host_id,
24
- Symbol access_strategy
25
+ Symbol access_strategy,
26
+ Symbol rw_mode
25
27
  ) -> void
26
28
 
27
29
  def self.dead_score_reached__reset_acquirer_position: (
@@ -31,7 +33,8 @@ module RedisQueuedLocks
31
33
  Integer queue_ttl,
32
34
  String acquirer_id,
33
35
  String host_id,
34
- Symbol access_strategy
36
+ Symbol access_strategy,
37
+ Symbol rw_mode
35
38
  ) -> void
36
39
 
37
40
  def self.extendable_reentrant_lock_obtained: (
@@ -42,7 +45,8 @@ module RedisQueuedLocks
42
45
  String acquirer_id,
43
46
  String host_id,
44
47
  Integer|Float acq_time,
45
- Symbol access_strategy
48
+ Symbol access_strategy,
49
+ Symbol rw_mode
46
50
  ) -> void
47
51
 
48
52
  def self.reentrant_lock_obtained: (
@@ -53,7 +57,8 @@ module RedisQueuedLocks
53
57
  String acquirer_id,
54
58
  String host_id,
55
59
  Integer|Float acq_time,
56
- Symbol access_strategy
60
+ Symbol access_strategy,
61
+ Symbol rw_mode
57
62
  ) -> void
58
63
 
59
64
  def self.lock_obtained: (
@@ -64,7 +69,8 @@ module RedisQueuedLocks
64
69
  String acquirer_id,
65
70
  String host_id,
66
71
  Integer|Float acq_time,
67
- Symbol access_strategy
72
+ Symbol access_strategy,
73
+ Symbol rw_mode
68
74
  ) -> void
69
75
  end
70
76
  end
@@ -13,7 +13,8 @@ module RedisQueuedLocks
13
13
  Integer queue_ttl,
14
14
  String acquirer_id,
15
15
  String host_id,
16
- Symbol access_strategy
16
+ Symbol access_strategy,
17
+ Symbol rw_mode
17
18
  ) -> void
18
19
 
19
20
  def self.rconn_fetched: (
@@ -24,7 +25,8 @@ module RedisQueuedLocks
24
25
  Integer queue_ttl,
25
26
  String acquirer_id,
26
27
  String host_id,
27
- Symbol access_strategy
28
+ Symbol access_strategy,
29
+ Symbol rw_mode
28
30
  ) -> void
29
31
 
30
32
  def self.same_process_conflict_detected: (
@@ -35,7 +37,8 @@ module RedisQueuedLocks
35
37
  Integer queue_ttl,
36
38
  String acquirer_id,
37
39
  String host_id,
38
- Symbol access_strategy
40
+ Symbol access_strategy,
41
+ Symbol rw_mode
39
42
  ) -> void
40
43
 
41
44
  def self.same_process_conflict_analyzed: (
@@ -47,6 +50,7 @@ module RedisQueuedLocks
47
50
  String acquirer_id,
48
51
  String host_id,
49
52
  Symbol access_strategy,
53
+ Symbol rw_mode,
50
54
  Symbol sp_conflict_status
51
55
  ) -> void
52
56
 
@@ -59,6 +63,7 @@ module RedisQueuedLocks
59
63
  String acquirer_id,
60
64
  String host_id,
61
65
  Symbol access_strategy,
66
+ Symbol rw_mode,
62
67
  Symbol sp_conflict_status,
63
68
  Integer? ttl,
64
69
  ::Float spc_processed_timestamp
@@ -73,6 +78,7 @@ module RedisQueuedLocks
73
78
  String acquirer_id,
74
79
  String host_id,
75
80
  Symbol access_strategy,
81
+ Symbol rw_mode,
76
82
  Symbol sp_conflict_status,
77
83
  ::Float spc_processed_timestamp
78
84
  ) -> void
@@ -86,6 +92,21 @@ module RedisQueuedLocks
86
92
  String acquirer_id,
87
93
  String host_id,
88
94
  Symbol access_strategy,
95
+ Symbol rw_mode,
96
+ Symbol sp_conflict_status,
97
+ ::Float spc_processed_timestamp
98
+ ) -> void
99
+
100
+ def self.single_process_lock_conflict__lock_upgrade: (
101
+ RQL::loggerObj logger,
102
+ bool log_sampled,
103
+ bool log_lock_try,
104
+ String lock_key,
105
+ Integer queue_ttl,
106
+ String acquirer_id,
107
+ String host_id,
108
+ Symbol access_strategy,
109
+ Symbol rw_mode,
89
110
  Symbol sp_conflict_status,
90
111
  ::Float spc_processed_timestamp
91
112
  ) -> void
@@ -98,7 +119,8 @@ module RedisQueuedLocks
98
119
  Integer queue_ttl,
99
120
  String acquirer_id,
100
121
  String host_id,
101
- Symbol access_strategy
122
+ Symbol access_strategy,
123
+ Symbol rw_mode
102
124
  ) -> void
103
125
 
104
126
  def self.remove_expired_acqs: (
@@ -109,7 +131,8 @@ module RedisQueuedLocks
109
131
  Integer queue_ttl,
110
132
  String acquirer_id,
111
133
  String host_id,
112
- Symbol access_strategy
134
+ Symbol access_strategy,
135
+ Symbol rw_mode
113
136
  ) -> void
114
137
 
115
138
  def self.get_first_from_queue: (
@@ -121,6 +144,7 @@ module RedisQueuedLocks
121
144
  String acquirer_id,
122
145
  String host_id,
123
146
  Symbol access_strategy,
147
+ Symbol rw_mode,
124
148
  String? waiting_acquirer
125
149
  ) -> void
126
150
 
@@ -132,7 +156,8 @@ module RedisQueuedLocks
132
156
  Integer queue_ttl,
133
157
  String acquirer_id,
134
158
  String host_id,
135
- Symbol access_strategy
159
+ Symbol access_strategy,
160
+ Symbol rw_mode
136
161
  ) -> void
137
162
 
138
163
  def self.exit__no_first: (
@@ -144,6 +169,7 @@ module RedisQueuedLocks
144
169
  String acquirer_id,
145
170
  String host_id,
146
171
  Symbol access_strategy,
172
+ Symbol rw_mode,
147
173
  String? waiting_acquirer,
148
174
  Hash[String,untyped] current_lock_data
149
175
  ) -> void
@@ -157,11 +183,51 @@ module RedisQueuedLocks
157
183
  String acquirer_id,
158
184
  String host_id,
159
185
  Symbol access_strategy,
186
+ Symbol rw_mode,
160
187
  String? waiting_acquirer,
161
188
  String locked_by_acquirer,
162
189
  Hash[String,untyped] current_lock_data
163
190
  ) -> void
164
191
 
192
+ def self.exit__write_request_ahead: (
193
+ RQL::loggerObj logger,
194
+ bool log_sampled,
195
+ bool log_lock_try,
196
+ String lock_key,
197
+ Integer queue_ttl,
198
+ String acquirer_id,
199
+ String host_id,
200
+ Symbol access_strategy,
201
+ Symbol rw_mode,
202
+ String ahead_acquirer
203
+ ) -> void
204
+
205
+ def self.exit__read_request_ahead: (
206
+ RQL::loggerObj logger,
207
+ bool log_sampled,
208
+ bool log_lock_try,
209
+ String lock_key,
210
+ Integer queue_ttl,
211
+ String acquirer_id,
212
+ String host_id,
213
+ Symbol access_strategy,
214
+ Symbol rw_mode,
215
+ String ahead_acquirer
216
+ ) -> void
217
+
218
+ def self.exit__read_lock_still_obtained: (
219
+ RQL::loggerObj logger,
220
+ bool log_sampled,
221
+ bool log_lock_try,
222
+ String lock_key,
223
+ Integer queue_ttl,
224
+ String acquirer_id,
225
+ String host_id,
226
+ Symbol access_strategy,
227
+ Symbol rw_mode,
228
+ String? waiting_acquirer
229
+ ) -> void
230
+
165
231
  def self.obtain__free_to_acquire: (
166
232
  RQL::loggerObj logger,
167
233
  bool log_sampled,
@@ -170,7 +236,8 @@ module RedisQueuedLocks
170
236
  Integer queue_ttl,
171
237
  String acquirer_id,
172
238
  String host_id,
173
- Symbol access_strategy
239
+ Symbol access_strategy,
240
+ Symbol rw_mode
174
241
  ) -> void
175
242
  end
176
243
  end
@@ -17,7 +17,8 @@ module RedisQueuedLocks
17
17
  # acq_id: String,
18
18
  # hst_id: String,
19
19
  # ts: Integer?,
20
- # ttl: Integer?
20
+ # ttl: Integer?,
21
+ # rw_mode: Symbol
21
22
  # }
22
23
  # }
23
24
 
@@ -29,7 +30,8 @@ module RedisQueuedLocks
29
30
  Symbol read_write_mode,
30
31
  String lock_key_queue,
31
32
  String read_lock_key_queue,
32
- String write_lock_key_queue,
33
+ String lock_readers_key,
34
+ String read_lock_key,
33
35
  String acquirer_id,
34
36
  String host_id,
35
37
  Integer|Float acquirer_position,
@@ -11,6 +11,9 @@ module RedisQueuedLocks
11
11
  RC::client redis,
12
12
  RQL::loggerObj logger,
13
13
  String lock_key,
14
+ String lock_readers_key,
15
+ String read_lock_key,
16
+ Symbol rw_mode,
14
17
  String acquirer_id,
15
18
  String host_id,
16
19
  Symbol access_strategy,
@@ -12,7 +12,8 @@ module RedisQueuedLocks
12
12
  Integer queue_ttl,
13
13
  String acquirer_id,
14
14
  String host_id,
15
- Symbol access_strategy
15
+ Symbol access_strategy,
16
+ Symbol rw_mode
16
17
  ) -> void
17
18
 
18
19
  def self.decrease_lock: (
@@ -23,7 +24,8 @@ module RedisQueuedLocks
23
24
  Integer queue_ttl,
24
25
  String acquirer_id,
25
26
  String host_id,
26
- Symbol access_strategy
27
+ Symbol access_strategy,
28
+ Symbol rw_mode
27
29
  ) -> void
28
30
  end
29
31
  end
@@ -6,11 +6,14 @@ module RedisQueuedLocks
6
6
  module ExtendLockTTL
7
7
  EXTEND_LOCK_PTTL: String
8
8
 
9
- type extendResult = { ok: bool, result: Symbol }
9
+ type extendResult = { ok: bool, result: { extended_locks_count: Integer } | Symbol }
10
10
  def self.extend_lock_ttl: (
11
11
  RC::client redis_client,
12
12
  String lock_name,
13
13
  Integer milliseconds,
14
+ Symbol read_write_mode,
15
+ bool all_read_locks,
16
+ String acquirer_id,
14
17
  RQL::loggerObj logger,
15
18
  RQL::instrObj instrumenter,
16
19
  untyped? instrument,
@@ -23,6 +26,21 @@ module RedisQueuedLocks
23
26
  RQL::Instrument::samplerObj instr_sampler,
24
27
  bool instr_sample_this
25
28
  ) -> extendResult
29
+
30
+ private def self.extend_read_lock_ttl: (
31
+ RC::client redis_client,
32
+ String lock_name,
33
+ String lock_key,
34
+ String acquirer_id,
35
+ Integer milliseconds
36
+ ) -> extendResult
37
+
38
+ private def self.extend_all_read_locks_ttl: (
39
+ RC::client redis_client,
40
+ String lock_name,
41
+ String lock_key,
42
+ Integer milliseconds
43
+ ) -> extendResult
26
44
  end
27
45
  end
28
46
  end
@@ -3,8 +3,16 @@ use RedisClient as RC
3
3
  module RedisQueuedLocks
4
4
  module Acquirer
5
5
  module LockInfo
6
- type lockInfo = Hash[String,String|Float|Integer]
6
+ type readerInfo = Hash[String,String|Float|Integer|nil]
7
+ type lockInfo = Hash[String,String|Float|Integer|Array[readerInfo]]
7
8
  def self.lock_info: (RC::client redis_client, String lock_name) -> lockInfo?
9
+ private def self.read_lock_info: (
10
+ RC::client redis_client,
11
+ String lock_name,
12
+ String lock_key,
13
+ Array[String] redis_time,
14
+ Array[[String, Float]] read_locks
15
+ ) -> lockInfo?
8
16
  end
9
17
  end
10
18
  end
@@ -3,14 +3,23 @@ use RedisClient as RC
3
3
  module RedisQueuedLocks
4
4
  module Acquirer
5
5
  module Locks
6
+ type readerInfo = Hash[String,String|Float|Integer|nil]
7
+ type lockInfo = Hash[String,String|Float|Integer|Array[readerInfo]]
6
8
  type lockList = Set[String]
7
- type locksInfo = Set[{ lock: String, status: Symbol, info: Hash[String,String|Float|Integer] }]
9
+ type locksInfo = Set[{ lock: String, status: Symbol, info: lockInfo }]
8
10
  type locks = lockList | locksInfo
9
11
 
10
12
  def self.locks: (RC::client redis_client, scan_size: Integer, with_info: bool) -> locks
11
13
 
12
14
  private def self.scan_locks: (RC::client redis_client, Integer scan_size) -> lockList
13
15
  private def self.extract_locks_info: (RC::client redis_client, Set[::String] lock_keys) -> locksInfo
16
+ private def self.read_lock_info: (
17
+ RC::client redis_client,
18
+ String lock_name,
19
+ String lock_key,
20
+ Array[String] redis_time,
21
+ Array[[String, Float]] read_locks
22
+ ) -> lockInfo?
14
23
  end
15
24
  end
16
25
  end
@@ -3,10 +3,8 @@ use RedisClient as RC
3
3
  module RedisQueuedLocks
4
4
  module Acquirer
5
5
  module QueueInfo
6
- type queueInfo = {
7
- 'lock_queue' => String,
8
- 'queue' => Array[{ 'acq_id' => String, 'score' => Integer|Float }]
9
- }
6
+ type queueRequest = Hash[String,String|Integer|Float]
7
+ type queueInfo = Hash[String,String|Array[queueRequest]]
10
8
  def self.queue_info: (RC::client redis_client, String lock_name) -> queueInfo?
11
9
  end
12
10
  end
@@ -4,7 +4,7 @@ module RedisQueuedLocks
4
4
  module Acquirer
5
5
  module Queues
6
6
  type queueList = Set[String]
7
- type queuesInfo = Set[{ queue: String, requests: Array[Hash[String,Float]] }]
7
+ type queuesInfo = Set[{ queue: String, requests: Array[Hash[String,String|Float]] }]
8
8
  type queues = queueList | queuesInfo
9
9
 
10
10
  def self.queues: (RC::client redis_client, scan_size: Integer, with_info: bool) -> queues
@@ -32,7 +32,14 @@ module RedisQueuedLocks
32
32
  ) -> releaseResult
33
33
 
34
34
  type fullReleaseResult = { ok: bool, result: { queue: Symbol, lock: Symbol } }
35
- private def self.fully_release_lock: (RC::client redis, String lock_key, String lock_key_queue) -> fullReleaseResult
35
+ private def self.fully_release_lock: (
36
+ RC::client redis,
37
+ String lock_name,
38
+ String lock_key,
39
+ String lock_key_queue,
40
+ String read_lock_key_queue,
41
+ String lock_readers_key
42
+ ) -> fullReleaseResult
36
43
  end
37
44
  end
38
45
  end
@@ -0,0 +1,44 @@
1
+ use RedisQueuedLocks as RQL
2
+ use RedisClient as RC
3
+
4
+ module RedisQueuedLocks
5
+ module Acquirer
6
+ module ReleaseReadLock
7
+ extend RQL::Utilities
8
+
9
+ type releaseResult = {
10
+ ok: bool,
11
+ result: {
12
+ rel_time: Integer|Float,
13
+ rel_key: String,
14
+ rel_acq_id: String,
15
+ lock_res: Symbol
16
+ }
17
+ }
18
+ def self.release_read_lock: (
19
+ RC::client redis,
20
+ String lock_name,
21
+ String acquirer_id,
22
+ RQL::instrObj instrumenter,
23
+ RQL::loggerObj logger,
24
+ untyped? instrument,
25
+ bool log_sampling_enabled,
26
+ Integer log_sampling_percent,
27
+ RQL::Logging::samplerObj log_sampler,
28
+ bool log_sample_this,
29
+ bool instr_sampling_enabled,
30
+ Integer instr_sampling_percent,
31
+ RQL::Instrument::samplerObj instr_sampler,
32
+ bool instr_sample_this
33
+ ) -> releaseResult
34
+
35
+ type fullReleaseResult = { ok: bool, result: { lock: Symbol } }
36
+ private def self.fully_release_read_lock: (
37
+ RC::client redis,
38
+ String lock_readers_key,
39
+ String read_lock_key,
40
+ String acquirer_id
41
+ ) -> fullReleaseResult
42
+ end
43
+ end
44
+ end