redis_queued_locks 0.0.25 → 0.0.27

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c22d05a7cd7efbb64d23815a549ac668643635c764055cd74d4b935676e2c1f
4
- data.tar.gz: 97325d6296b8cb5754bbad368226a9a5effe60528d7962419f5b4dbbd97f3b2a
3
+ metadata.gz: f9d7bd4d48e34f520e1e7675030a15a346eca0f89429b500b7937ef36cf8107b
4
+ data.tar.gz: 7c331e2a5d728a78ce8009bc6d1e97621bab61ad336683e45b52063f2fff1715
5
5
  SHA512:
6
- metadata.gz: 0cffa3d5acfc3ec669d102eeec79ab81e1b3ccdd20cfe8ea3e6625a8acb3d847d0d8ed8343039ed042dfedb8ab5c0e4b928d3fca05c27ce0d75991772a0ebd77
7
- data.tar.gz: 88702b3fecaac8f2e1857aed831e8d8ab5b1f871ee2248b76f27969257d695d9df8b0edb456995d39e985e05236068c95fd4b510bb25df6d7611f6eb6d9b9694
6
+ metadata.gz: 33491d78f0a847f90ed27792ae3edd90388d78fb4098cd6eae00b85ea13c5353523f252f1cf83e01918bce502b3ad5735825e5f642122b0a15f6d301df12f5f1
7
+ data.tar.gz: a18017f9c1bc2559fbd6c723ce1fccc99c7041f6952e535dba31e14a5029abf43c215c6abcd0aaf514d4d670614882255e2b356c3c214a83b77265a826fe16e0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.0.27] - 2024-03-21
4
+ ### Changed
5
+ - Better acquier position accuracy: acquier position in lock queue
6
+ should be represented as EPOCH in seconds+microseconds (previously: simply in seconds);
7
+
8
+ ## [0.0.26] - 2024-03-21
9
+ ### Added
10
+ - Logging: add `acquier_id`;
11
+
3
12
  ## [0.0.25] - 2024-03-21
4
13
  ### Changed
5
14
  - Minor logs stylization;
@@ -10,7 +19,7 @@
10
19
 
11
20
  ## [0.0.23] - 2024-03-21
12
21
  ### Changed
13
- - Composed redis commands are invoked on the one conenction
22
+ - Composed redis commands are invoked from the same *one* conenction
14
23
  (instead of mutiple connection fetching from redis connection pool on each redis command);
15
24
 
16
25
  ## [0.0.22] - 2024-03-21
@@ -40,7 +40,11 @@ module RedisQueuedLocks::Acquier::AcquireLock::TryToLock
40
40
 
41
41
  if log_lock_try
42
42
  run_non_critical do
43
- logger.debug("[redis_queued_locks.try_lock_start] lock_key => '#{lock_key}'")
43
+ logger.debug(
44
+ "[redis_queued_locks.try_lock_start] " \
45
+ "lock_key => '#{lock_key}' " \
46
+ "acq_id => '#{acquier_id}'"
47
+ )
44
48
  end
45
49
  end
46
50
 
@@ -48,7 +52,11 @@ module RedisQueuedLocks::Acquier::AcquireLock::TryToLock
48
52
  result = redis.with do |rconn|
49
53
  if log_lock_try
50
54
  run_non_critical do
51
- logger.debug("[redis_queued_locks.try_lock_rconn_fetched] lock_key => '#{lock_key}'")
55
+ logger.debug(
56
+ "[redis_queued_locks.try_lock_rconn_fetched] " \
57
+ "lock_key => '#{lock_key}' " \
58
+ "acq_id => '#{acquier_id}'"
59
+ )
52
60
  end
53
61
  end
54
62
 
@@ -139,7 +147,7 @@ module RedisQueuedLocks::Acquier::AcquireLock::TryToLock
139
147
  'HSET',
140
148
  lock_key,
141
149
  'acq_id', acquier_id,
142
- 'ts', (timestamp = Time.now.to_i),
150
+ 'ts', (timestamp = Time.now.to_f),
143
151
  'ini_ttl', ttl
144
152
  )
145
153
 
@@ -139,7 +139,8 @@ module RedisQueuedLocks::Acquier::AcquireLock
139
139
  run_non_critical do
140
140
  logger.debug(
141
141
  "[redis_queued_locks.start_lock_obtaining] " \
142
- "lock_key => '#{lock_key}'"
142
+ "lock_key => '#{lock_key}' " \
143
+ "acq_id => '#{acquier_id}'"
143
144
  )
144
145
  end
145
146
 
@@ -175,6 +176,7 @@ module RedisQueuedLocks::Acquier::AcquireLock
175
176
  logger.debug(
176
177
  "[redis_queued_locks.lock_obtained] " \
177
178
  "lock_key => '#{result[:lock_key]}' " \
179
+ "acq_id: => '#{acquier_id}' " \
178
180
  "acq_time => #{acq_time} (ms)"
179
181
  )
180
182
  end
@@ -11,7 +11,7 @@ module RedisQueuedLocks::Acquier::LockInfo
11
11
  # - result format: {
12
12
  # lock_key: "rql:lock:your_lockname", # acquired lock key
13
13
  # acq_id: "rql:acq:process_id/thread_id", # lock acquier identifier
14
- # ts: 123456789, # <locked at> time stamp (epoch)
14
+ # ts: 123456789.2649841, # <locked at> time stamp (epoch, seconds.microseconds)
15
15
  # ini_ttl: 123456789, # initial lock key ttl (milliseconds),
16
16
  # rem_ttl: 123456789, # remaining lock key ttl (milliseconds)
17
17
  # }
@@ -46,7 +46,7 @@ module RedisQueuedLocks::Acquier::LockInfo
46
46
  {
47
47
  lock_key: lock_key,
48
48
  acq_id: hget_cmd_res['acq_id'],
49
- ts: Integer(hget_cmd_res['ts']),
49
+ ts: Float(hget_cmd_res['ts']),
50
50
  ini_ttl: Integer(hget_cmd_res['ini_ttl']),
51
51
  rem_ttl: ((pttl_cmd_res == -1) ? Infinity : pttl_cmd_res)
52
52
  }
@@ -65,21 +65,21 @@ module RedisQueuedLocks::Resource
65
65
  "rql:lock_queue:#{lock_name}"
66
66
  end
67
67
 
68
- # @return [Integer] Redis's <Set> score that is calculated from the time (epoch) as an integer.
68
+ # @return [Float] Redis's <Set> score that is calculated from the time (epoch) as a float.
69
69
  #
70
70
  # @api private
71
71
  # @since 0.1.0
72
72
  def calc_initial_acquier_position
73
- Time.now.to_i
73
+ Time.now.to_f
74
74
  end
75
75
 
76
76
  # @param queue_ttl [Integer] In seconds
77
- # @return [Integer] Redis's <Set> score barrier before wich all other acquiers are removed.
77
+ # @return [Float] Redis's <Set> score barrier for acquiers that should be removed from queue.
78
78
  #
79
79
  # @api private
80
80
  # @since 0.1.0
81
81
  def acquier_dead_score(queue_ttl)
82
- Time.now.to_i - queue_ttl
82
+ Time.now.to_f - queue_ttl
83
83
  end
84
84
 
85
85
  # @param lock_queue [String]
@@ -5,6 +5,6 @@ module RedisQueuedLocks
5
5
  #
6
6
  # @api public
7
7
  # @since 0.0.1
8
- # @version 0.0.25
9
- VERSION = '0.0.25'
8
+ # @version 0.0.27
9
+ VERSION = '0.0.27'
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_queued_locks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.25
4
+ version: 0.0.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rustam Ibragimov