redis_queued_locks 1.1.0 → 1.3.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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -3
  3. data/README.md +262 -60
  4. data/lib/redis_queued_locks/acquier/acquire_lock/delay_execution.rb +2 -2
  5. data/lib/redis_queued_locks/acquier/acquire_lock/try_to_lock.rb +239 -12
  6. data/lib/redis_queued_locks/acquier/acquire_lock/with_acq_timeout.rb +2 -2
  7. data/lib/redis_queued_locks/acquier/acquire_lock/yield_expire.rb +115 -0
  8. data/lib/redis_queued_locks/acquier/acquire_lock.rb +200 -89
  9. data/lib/redis_queued_locks/acquier/clear_dead_requests.rb +3 -3
  10. data/lib/redis_queued_locks/acquier/extend_lock_ttl.rb +3 -3
  11. data/lib/redis_queued_locks/acquier/is_locked.rb +2 -2
  12. data/lib/redis_queued_locks/acquier/is_queued.rb +2 -2
  13. data/lib/redis_queued_locks/acquier/keys.rb +2 -2
  14. data/lib/redis_queued_locks/acquier/lock_info.rb +19 -3
  15. data/lib/redis_queued_locks/acquier/locks.rb +13 -4
  16. data/lib/redis_queued_locks/acquier/queue_info.rb +2 -2
  17. data/lib/redis_queued_locks/acquier/queues.rb +4 -4
  18. data/lib/redis_queued_locks/acquier/release_all_locks.rb +4 -4
  19. data/lib/redis_queued_locks/acquier/release_lock.rb +4 -4
  20. data/lib/redis_queued_locks/acquier.rb +1 -1
  21. data/lib/redis_queued_locks/client.rb +50 -22
  22. data/lib/redis_queued_locks/debugger/interface.rb +4 -4
  23. data/lib/redis_queued_locks/debugger.rb +8 -8
  24. data/lib/redis_queued_locks/errors.rb +10 -6
  25. data/lib/redis_queued_locks/instrument/active_support.rb +2 -2
  26. data/lib/redis_queued_locks/instrument/void_notifier.rb +2 -2
  27. data/lib/redis_queued_locks/instrument.rb +2 -2
  28. data/lib/redis_queued_locks/logging/void_logger.rb +10 -10
  29. data/lib/redis_queued_locks/logging.rb +10 -3
  30. data/lib/redis_queued_locks/resource.rb +22 -16
  31. data/lib/redis_queued_locks/utilities.rb +2 -2
  32. data/lib/redis_queued_locks/version.rb +2 -2
  33. data/lib/redis_queued_locks.rb +2 -2
  34. metadata +4 -4
  35. data/lib/redis_queued_locks/acquier/acquire_lock/yield_with_expire.rb +0 -72
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # @api private
4
- # @since 0.1.0
4
+ # @since 1.0.0
5
5
  module RedisQueuedLocks::Acquier::Queues
6
6
  class << self
7
7
  # @param redis_client [RedisClient]
@@ -10,7 +10,7 @@ module RedisQueuedLocks::Acquier::Queues
10
10
  # @return [Set<String>,Set<Hash<Symbol,Any>>]
11
11
  #
12
12
  # @api private
13
- # @since 0.1.0
13
+ # @since 1.0.0
14
14
  def queues(redis_client, scan_size:, with_info:)
15
15
  redis_client.with do |rconn|
16
16
  lock_queues = scan_queues(rconn, scan_size)
@@ -25,7 +25,7 @@ module RedisQueuedLocks::Acquier::Queues
25
25
  # @return [Set<String>]
26
26
  #
27
27
  # @api private
28
- # @since 0.1.0
28
+ # @since 1.0.0
29
29
  def scan_queues(redis_client, scan_size)
30
30
  Set.new.tap do |lock_queues|
31
31
  redis_client.scan(
@@ -44,7 +44,7 @@ module RedisQueuedLocks::Acquier::Queues
44
44
  # @return [Set<Hash<Symbol,Any>>]
45
45
  #
46
46
  # @api private
47
- # @since 0.1.0
47
+ # @since 1.0.0
48
48
  def extract_queues_info(redis_client, lock_queues)
49
49
  # TODO: refactor with RedisQueuedLocks::Acquier::QueueInfo
50
50
  Set.new.tap do |seeded_queues|
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # @api private
4
- # @since 0.1.0
4
+ # @since 1.0.0
5
5
  module RedisQueuedLocks::Acquier::ReleaseAllLocks
6
- # @since 0.1.0
6
+ # @since 1.0.0
7
7
  extend RedisQueuedLocks::Utilities
8
8
 
9
9
  class << self
@@ -27,7 +27,7 @@ module RedisQueuedLocks::Acquier::ReleaseAllLocks
27
27
  # Format: { ok: true, result: Hash<Symbol,Numeric> }
28
28
  #
29
29
  # @api private
30
- # @since 0.1.0
30
+ # @since 1.0.0
31
31
  def release_all_locks(redis, batch_size, logger, instrumenter, instrument)
32
32
  rel_start_time = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
33
33
  fully_release_all_locks(redis, batch_size) => { ok:, result: }
@@ -59,7 +59,7 @@ module RedisQueuedLocks::Acquier::ReleaseAllLocks
59
59
  # - Exmaple: { ok: true, result: { rel_key_cnt: 12345 } }
60
60
  #
61
61
  # @api private
62
- # @since 0.1.0
62
+ # @since 1.0.0
63
63
  def fully_release_all_locks(redis, batch_size)
64
64
  result = redis.with do |rconn|
65
65
  rconn.pipelined do |pipeline|
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # @api private
4
- # @since 0.1.0
4
+ # @since 1.0.0
5
5
  module RedisQueuedLocks::Acquier::ReleaseLock
6
- # @since 0.1.0
6
+ # @since 1.0.0
7
7
  extend RedisQueuedLocks::Utilities
8
8
 
9
9
  class << self
@@ -27,7 +27,7 @@ module RedisQueuedLocks::Acquier::ReleaseLock
27
27
  # Format: { ok: true/false, result: Hash<Symbol,Numeric|String|Symbol> }
28
28
  #
29
29
  # @api private
30
- # @since 0.1.0
30
+ # @since 1.0.0
31
31
  def release_lock(redis, lock_name, instrumenter, logger)
32
32
  lock_key = RedisQueuedLocks::Resource.prepare_lock_key(lock_name)
33
33
  lock_key_queue = RedisQueuedLocks::Resource.prepare_lock_queue(lock_name)
@@ -76,7 +76,7 @@ module RedisQueuedLocks::Acquier::ReleaseLock
76
76
  # }
77
77
  #
78
78
  # @api private
79
- # @since 0.1.0
79
+ # @since 1.0.0
80
80
  def fully_release_lock(redis, lock_key, lock_key_queue)
81
81
  result = redis.with do |rconn|
82
82
  rconn.multi do |transact|
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # @api private
4
- # @since 0.1.0
4
+ # @since 1.0.0
5
5
  module RedisQueuedLocks::Acquier
6
6
  require_relative 'acquier/acquire_lock'
7
7
  require_relative 'acquier/release_lock'
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # @api public
4
- # @since 0.1.0
4
+ # @since 1.0.0
5
5
  # rubocop:disable Metrics/ClassLength
6
6
  class RedisQueuedLocks::Client
7
- # @since 0.1.0
7
+ # @since 1.0.0
8
8
  include Qonfig::Configurable
9
9
 
10
10
  configuration do
@@ -22,6 +22,7 @@ class RedisQueuedLocks::Client
22
22
  setting :log_lock_try, false
23
23
  setting :dead_request_ttl, (1 * 24 * 60 * 60 * 1000) # NOTE: 1 day in milliseconds
24
24
  setting :is_timed_by_default, false
25
+ setting :default_conflict_strategy, :wait_for_lock
25
26
 
26
27
  validate('retry_count') { |val| val == nil || (val.is_a?(::Integer) && val >= 0) }
27
28
  validate('retry_delay') { |val| val.is_a?(::Integer) && val >= 0 }
@@ -36,12 +37,20 @@ class RedisQueuedLocks::Client
36
37
  validate('log_lock_try', :boolean)
37
38
  validate('dead_request_ttl') { |val| val.is_a?(::Integer) && val > 0 }
38
39
  validate('is_timed_by_default', :boolean)
40
+ validate('default_conflict_strategy') do |val|
41
+ # rubocop:disable Layout/MultilineOperationIndentation
42
+ val == :work_through ||
43
+ val == :extendable_work_through ||
44
+ val == :wait_for_lock ||
45
+ val == :dead_locking
46
+ # rubocop:enable Layout/MultilineOperationIndentation
47
+ end
39
48
  end
40
49
 
41
50
  # @return [RedisClient]
42
51
  #
43
52
  # @api private
44
- # @since 0.1.0
53
+ # @since 1.0.0
45
54
  attr_reader :redis_client
46
55
 
47
56
  # NOTE: attr_access here is chosen intentionally in order to have an ability to change
@@ -49,7 +58,7 @@ class RedisQueuedLocks::Client
49
58
  # @return [String]
50
59
  #
51
60
  # @api private
52
- # @since 0.1.0
61
+ # @since 1.0.0
53
62
  attr_accessor :uniq_identity
54
63
 
55
64
  # @param redis_client [RedisClient]
@@ -60,7 +69,7 @@ class RedisQueuedLocks::Client
60
69
  # @return [void]
61
70
  #
62
71
  # @api public
63
- # @since 0.1.0
72
+ # @since 1.0.0
64
73
  def initialize(redis_client, &configs)
65
74
  configure(&configs)
66
75
  @uniq_identity = config[:uniq_identifier].call
@@ -96,19 +105,31 @@ class RedisQueuedLocks::Client
96
105
  # already obtained;
97
106
  # - Should the logic exit immidietly after the first try if the lock was obtained
98
107
  # by another process while the lock request queue was initially empty;
108
+ # @option conflict_strategy [Symbol]
109
+ # - The conflict strategy mode for cases when the process that obtained the lock
110
+ # want to acquire this lock again;
111
+ # - By default uses `:wait_for_lock` strategy;
112
+ # - pre-confured in `config[:default_conflict_strategy]`;
113
+ # - Supports:
114
+ # - `:work_through` - continue working under the lock without lock's TTL extension;
115
+ # - `:extendable_work_through` - continue working under the lock with lock's TTL extension;
116
+ # - `:wait_for_lock` - (default) - work in classic way
117
+ # (with timeouts, retry delays, retry limits, etc - in classic way :));
118
+ # - `:dead_locking` - fail with deadlock exception;
99
119
  # @option meta [NilClass,Hash<String|Symbol,Any>]
100
120
  # - A custom metadata wich will be passed to the lock data in addition to the existing data;
101
121
  # - Metadata can not contain reserved lock data keys;
102
122
  # @option logger [::Logger,#debug]
103
123
  # - Logger object used from the configuration layer (see config[:logger]);
104
124
  # - See `RedisQueuedLocks::Logging::VoidLogger` for example;
125
+ # - Supports `SemanticLogger::Logger` (see "semantic_logger" gem)
105
126
  # @option log_lock_try [Boolean]
106
127
  # - should be logged the each try of lock acquiring (a lot of logs can
107
128
  # be generated depending on your retry configurations);
108
129
  # - see `config[:log_lock_try]`;
109
130
  # @option instrument [NilClass,Any]
110
- # - Custom instrumentation data wich will be passed to the instrumenter's payload
111
- # with :instrument key;
131
+ # - Custom instrumentation data wich will be passed to the instrumenter's payload
132
+ # with :instrument key;
112
133
  # @param block [Block]
113
134
  # A block of code that should be executed after the successfully acquired lock.
114
135
  # @return [RedisQueuedLocks::Data,Hash<Symbol,Any>,yield]
@@ -116,7 +137,8 @@ class RedisQueuedLocks::Client
116
137
  # - If block is given the result of block's yeld will be returned.
117
138
  #
118
139
  # @api public
119
- # @since 0.1.0
140
+ # @since 1.0.0
141
+ # @version 1.3.0
120
142
  def lock(
121
143
  lock_name,
122
144
  ttl: config[:default_lock_ttl],
@@ -128,6 +150,7 @@ class RedisQueuedLocks::Client
128
150
  retry_jitter: config[:retry_jitter],
129
151
  raise_errors: false,
130
152
  fail_fast: false,
153
+ conflict_strategy: config[:default_conflict_strategy],
131
154
  identity: uniq_identity,
132
155
  meta: nil,
133
156
  logger: config[:logger],
@@ -153,6 +176,7 @@ class RedisQueuedLocks::Client
153
176
  instrumenter: config[:instrumenter],
154
177
  identity:,
155
178
  fail_fast:,
179
+ conflict_strategy:,
156
180
  meta:,
157
181
  logger: config[:logger],
158
182
  log_lock_try: config[:log_lock_try],
@@ -164,7 +188,8 @@ class RedisQueuedLocks::Client
164
188
  # @note See #lock method signature.
165
189
  #
166
190
  # @api public
167
- # @since 0.1.0
191
+ # @since 1.0.0
192
+ # @version 1.3.0
168
193
  def lock!(
169
194
  lock_name,
170
195
  ttl: config[:default_lock_ttl],
@@ -175,6 +200,7 @@ class RedisQueuedLocks::Client
175
200
  retry_delay: config[:retry_delay],
176
201
  retry_jitter: config[:retry_jitter],
177
202
  fail_fast: false,
203
+ conflict_strategy: config[:default_conflict_strategy],
178
204
  identity: uniq_identity,
179
205
  meta: nil,
180
206
  logger: config[:logger],
@@ -198,6 +224,7 @@ class RedisQueuedLocks::Client
198
224
  log_lock_try:,
199
225
  meta:,
200
226
  instrument:,
227
+ conflict_strategy:,
201
228
  &block
202
229
  )
203
230
  end
@@ -219,7 +246,7 @@ class RedisQueuedLocks::Client
219
246
  # }
220
247
  #
221
248
  # @api public
222
- # @since 0.1.0
249
+ # @since 1.0.0
223
250
  def unlock(
224
251
  lock_name,
225
252
  logger: config[:logger],
@@ -238,7 +265,7 @@ class RedisQueuedLocks::Client
238
265
  # @return [Boolean]
239
266
  #
240
267
  # @api public
241
- # @since 0.1.0
268
+ # @since 1.0.0
242
269
  def locked?(lock_name)
243
270
  RedisQueuedLocks::Acquier::IsLocked.locked?(redis_client, lock_name)
244
271
  end
@@ -247,7 +274,7 @@ class RedisQueuedLocks::Client
247
274
  # @return [Boolean]
248
275
  #
249
276
  # @api public
250
- # @since 0.1.0
277
+ # @since 1.0.0
251
278
  def queued?(lock_name)
252
279
  RedisQueuedLocks::Acquier::IsQueued.queued?(redis_client, lock_name)
253
280
  end
@@ -256,7 +283,7 @@ class RedisQueuedLocks::Client
256
283
  # @return [Hash<String,String|Numeric>,NilClass]
257
284
  #
258
285
  # @api public
259
- # @since 0.1.0
286
+ # @since 1.0.0
260
287
  def lock_info(lock_name)
261
288
  RedisQueuedLocks::Acquier::LockInfo.lock_info(redis_client, lock_name)
262
289
  end
@@ -265,7 +292,7 @@ class RedisQueuedLocks::Client
265
292
  # @return [Hash<String|Array<Hash<String,String|Numeric>>,NilClass]
266
293
  #
267
294
  # @api public
268
- # @since 0.1.0
295
+ # @since 1.0.0
269
296
  def queue_info(lock_name)
270
297
  RedisQueuedLocks::Acquier::QueueInfo.queue_info(redis_client, lock_name)
271
298
  end
@@ -288,7 +315,7 @@ class RedisQueuedLocks::Client
288
315
  # - { ok: false, result: :async_expire_or_no_lock }
289
316
  #
290
317
  # @api public
291
- # @since 0.1.0
318
+ # @since 1.0.0
292
319
  def extend_lock_ttl(lock_name, milliseconds, logger: config[:logger])
293
320
  RedisQueuedLocks::Acquier::ExtendLockTTL.extend_lock_ttl(
294
321
  redis_client,
@@ -311,7 +338,7 @@ class RedisQueuedLocks::Client
311
338
  # Example: { ok: true, result { rel_key_cnt: 100, rel_time: 0.01 } }
312
339
  #
313
340
  # @api public
314
- # @since 0.1.0
341
+ # @since 1.0.0
315
342
  def clear_locks(
316
343
  batch_size: config[:lock_release_batch_size],
317
344
  logger: config[:logger],
@@ -345,7 +372,7 @@ class RedisQueuedLocks::Client
345
372
  # @return [Set<String>,Set<Hash<Symbol,Any>>]
346
373
  #
347
374
  # @api public
348
- # @since 0.1.0
375
+ # @since 1.0.0
349
376
  def locks(scan_size: config[:key_extraction_batch_size], with_info: false)
350
377
  RedisQueuedLocks::Acquier::Locks.locks(redis_client, scan_size:, with_info:)
351
378
  end
@@ -356,7 +383,7 @@ class RedisQueuedLocks::Client
356
383
  # @return [Set<Hash<String,Any>>]
357
384
  #
358
385
  # @api public
359
- # @since 0.1.0
386
+ # @since 1.0.0
360
387
  def locks_info(scan_size: config[:key_extraction_batch_size])
361
388
  locks(scan_size:, with_info: true)
362
389
  end
@@ -376,7 +403,7 @@ class RedisQueuedLocks::Client
376
403
  # @return [Set<String>,String<Hash<Symbol,Any>>]
377
404
  #
378
405
  # @api public
379
- # @since 0.1.0
406
+ # @since 1.0.0
380
407
  def queues(scan_size: config[:key_extraction_batch_size], with_info: false)
381
408
  RedisQueuedLocks::Acquier::Queues.queues(redis_client, scan_size:, with_info:)
382
409
  end
@@ -387,7 +414,7 @@ class RedisQueuedLocks::Client
387
414
  # @return [Set<Hash<Symbol,Any>>]
388
415
  #
389
416
  # @api public
390
- # @since 0.1.0
417
+ # @since 1.0.0
391
418
  def queues_info(scan_size: config[:key_extraction_batch_size])
392
419
  queues(scan_size:, with_info: true)
393
420
  end
@@ -396,7 +423,7 @@ class RedisQueuedLocks::Client
396
423
  # @return [Set<String>]
397
424
  #
398
425
  # @api public
399
- # @since 0.1.0
426
+ # @since 1.0.0
400
427
  def keys(scan_size: config[:key_extraction_batch_size])
401
428
  RedisQueuedLocks::Acquier::Keys.keys(redis_client, scan_size:)
402
429
  end
@@ -415,7 +442,8 @@ class RedisQueuedLocks::Client
415
442
  # Format: { ok: true, result: { processed_queus: Set<String> } }
416
443
  #
417
444
  # @api public
418
- # @since 0.1.0
445
+ # @since 1.0.0
446
+ # @version 1.1.0
419
447
  def clear_dead_requests(
420
448
  dead_ttl: config[:dead_request_ttl],
421
449
  scan_size: config[:lock_release_batch_size],
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # @api private
4
- # @since 0.1.0
4
+ # @since 1.0.0
5
5
  module RedisQueuedLocks::Debugger::Interface
6
6
  # @param message [String]
7
7
  # @return [void]
8
8
  #
9
9
  # @api private
10
- # @since 0.1.0
10
+ # @since 1.0.0
11
11
  def debug(message)
12
12
  RedisQueuedLocks::Debugger.debug(message)
13
13
  end
@@ -15,7 +15,7 @@ module RedisQueuedLocks::Debugger::Interface
15
15
  # @return [void]
16
16
  #
17
17
  # @api private
18
- # @since 0.1.0
18
+ # @since 1.0.0
19
19
  def enable_debugger!
20
20
  RedisQueuedLocks::Debugger.enable!
21
21
  end
@@ -23,7 +23,7 @@ module RedisQueuedLocks::Debugger::Interface
23
23
  # @return [void]
24
24
  #
25
25
  # @api private
26
- # @since 0.1.0
26
+ # @since 1.0.0
27
27
  def disable_debugger!
28
28
  RedisQueuedLocks::Debugger.disable!
29
29
  end
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # @api private
4
- # @since 0.1.0
4
+ # @since 1.0.0
5
5
  module RedisQueuedLocks::Debugger
6
6
  require_relative 'debugger/interface'
7
7
 
8
8
  # @return [String]
9
9
  #
10
10
  # @api private
11
- # @since 0.1.0
11
+ # @since 1.0.0
12
12
  DEBUG_ENABLED_METHOD = <<~METHOD_DECLARATION.strip.freeze
13
13
  def debug(message) = STDOUT.write("#\{message}\n")
14
14
  METHOD_DECLARATION
@@ -16,20 +16,20 @@ module RedisQueuedLocks::Debugger
16
16
  # @return [String]
17
17
  #
18
18
  # @api private
19
- # @since 0.1.0
19
+ # @since 1.0.0
20
20
  DEBUG_DISABLED_MEHTOD = <<~METHOD_DECLARATION.strip.freeze
21
21
  def debug(message); end
22
22
  METHOD_DECLARATION
23
23
 
24
24
  class << self
25
25
  # @api private
26
- # @since 0.1.0
26
+ # @since 1.0.0
27
27
  instance_variable_set(:@enabled, false)
28
28
 
29
29
  # @return [void]
30
30
  #
31
31
  # @api private
32
- # @since 0.1.0
32
+ # @since 1.0.0
33
33
  def enable!
34
34
  @enabled = true
35
35
  eval(DEBUG_ENABLED_METHOD)
@@ -38,7 +38,7 @@ module RedisQueuedLocks::Debugger
38
38
  # @return [void]
39
39
  #
40
40
  # @api private
41
- # @since 0.1.0
41
+ # @since 1.0.0
42
42
  def disable!
43
43
  @enabled = false
44
44
  eval(DEBUG_DISABLED_MEHTOD)
@@ -47,7 +47,7 @@ module RedisQueuedLocks::Debugger
47
47
  # @return [Boolean]
48
48
  #
49
49
  # @api private
50
- # @since 0.1.0
50
+ # @since 1.0.0
51
51
  def enabled?
52
52
  @enabled
53
53
  end
@@ -56,7 +56,7 @@ module RedisQueuedLocks::Debugger
56
56
  # @return [void]
57
57
  #
58
58
  # @api private
59
- # @since 0.1.0
59
+ # @since 1.0.0
60
60
  def debug(message); end
61
61
  end
62
62
  end
@@ -2,26 +2,30 @@
2
2
 
3
3
  module RedisQueuedLocks
4
4
  # @api public
5
- # @since 0.1.0
5
+ # @since 1.0.0
6
6
  Error = Class.new(::StandardError)
7
7
 
8
8
  # @api public
9
- # @since 0.1.0
9
+ # @since 1.0.0
10
10
  ArgumentError = Class.new(::ArgumentError)
11
11
 
12
12
  # @api public
13
- # @since 0.1.0
13
+ # @since 1.0.0
14
14
  LockAlreadyObtainedError = Class.new(Error)
15
15
 
16
16
  # @api public
17
- # @since 0.1.0
17
+ # @since 1.0.0
18
18
  LockAcquiermentTimeoutError = Class.new(Error)
19
19
 
20
20
  # @api public
21
- # @since 0.1.0
21
+ # @since 1.0.0
22
22
  LockAcquiermentRetryLimitError = Class.new(Error)
23
23
 
24
24
  # @api pulic
25
- # @since 0.1.0
25
+ # @since 1.0.0
26
26
  TimedLockTimeoutError = Class.new(Error)
27
+
28
+ # @api public
29
+ # @since 1.3.0
30
+ ConflictLockObtainError = Class.new(Error)
27
31
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # @api public
4
- # @since 0.1.0
4
+ # @since 1.0.0
5
5
  module RedisQueuedLocks::Instrument::ActiveSupport
6
6
  class << self
7
7
  # @param event [String]
@@ -9,7 +9,7 @@ module RedisQueuedLocks::Instrument::ActiveSupport
9
9
  # @return [void]
10
10
  #
11
11
  # @api public
12
- # @since 0.1.0
12
+ # @since 1.0.0
13
13
  def notify(event, payload = {})
14
14
  ::ActiveSupport::Notifications.instrument(event, payload)
15
15
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # @api public
4
- # @since 0.1.0
4
+ # @since 1.0.0
5
5
  module RedisQueuedLocks::Instrument::VoidNotifier
6
6
  class << self
7
7
  # @param event [String]
@@ -9,7 +9,7 @@ module RedisQueuedLocks::Instrument::VoidNotifier
9
9
  # @return [void]
10
10
  #
11
11
  # @api public
12
- # @since 0.1.0
12
+ # @since 1.0.0
13
13
  def notify(event, payload = {}); end
14
14
  end
15
15
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # @api public
4
- # @since 0.1.0
4
+ # @since 1.0.0
5
5
  module RedisQueuedLocks::Instrument
6
6
  require_relative 'instrument/void_notifier'
7
7
  require_relative 'instrument/active_support'
@@ -11,7 +11,7 @@ module RedisQueuedLocks::Instrument
11
11
  # @return [Boolean]
12
12
  #
13
13
  # @api public
14
- # @since 0.1.0
14
+ # @since 1.0.0
15
15
  def valid_interface?(instrumenter)
16
16
  if instrumenter == RedisQueuedLocks::Instrument::ActiveSupport
17
17
  # NOTE: active_support should be required in your app
@@ -1,43 +1,43 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # @api public
4
- # @since 0.1.0
4
+ # @since 1.0.0
5
5
  module RedisQueuedLocks::Logging::VoidLogger
6
6
  class << self
7
7
  # @api public
8
- # @since 0.1.0
8
+ # @since 1.0.0
9
9
  def warn(progname = nil, &block); end
10
10
 
11
11
  # @api public
12
- # @since 0.1.0
12
+ # @since 1.0.0
13
13
  def unknown(progname = nil, &block); end
14
14
 
15
15
  # @api public
16
- # @since 0.1.0
16
+ # @since 1.0.0
17
17
  def log(progname = nil, &block); end
18
18
 
19
19
  # @api public
20
- # @since 0.1.0
20
+ # @since 1.0.0
21
21
  def info(progname = nil, &block); end
22
22
 
23
23
  # @api public
24
- # @since 0.1.0
24
+ # @since 1.0.0
25
25
  def error(progname = nil, &block); end
26
26
 
27
27
  # @api public
28
- # @since 0.1.0
28
+ # @since 1.0.0
29
29
  def fatal(progname = nil, &block); end
30
30
 
31
31
  # @api public
32
- # @since 0.1.0
32
+ # @since 1.0.0
33
33
  def debug(progname = nil, &block); end
34
34
 
35
35
  # @api public
36
- # @since 0.1.0
36
+ # @since 1.0.0
37
37
  def add(*, &block); end
38
38
 
39
39
  # @api public
40
- # @since 0.1.0
40
+ # @since 1.0.0
41
41
  def <<(message); end
42
42
  end
43
43
  end
@@ -1,19 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # @api public
4
- # @since 0.1.0
4
+ # @since 1.0.0
5
5
  module RedisQueuedLocks::Logging
6
6
  require_relative 'logging/void_logger'
7
7
 
8
8
  class << self
9
- # @param logger [::Logger,#debug]
9
+ # @param logger [::Logger,#debug,::SemanticLogger::Logger]
10
10
  # @return [Boolean]
11
11
  #
12
12
  # @api public
13
- # @since 0.1.0
13
+ # @since 1.0.0
14
+ # @version 1.2.0
14
15
  def valid_interface?(logger)
15
16
  return true if logger.is_a?(::Logger)
16
17
 
18
+ # NOTE:
19
+ # - convinient/conventional way to support the popular `semantic_logger` library
20
+ # - see https://logger.rocketjob.io/
21
+ # - see https://github.com/reidmorrison/semantic_logger
22
+ return true if defined?(::SemanticLogger::Logger) && logger.is_a?(::SemanticLogger::Logger)
23
+
17
24
  # NOTE: should provide `#debug` method.
18
25
  return false unless logger.respond_to?(:debug)
19
26