redis_queued_locks 0.0.3 → 0.0.4

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: 5dbd11cefb9d18a816eb4c63fe1178f87325c30d75efc2bc806d29f41994fc2c
4
- data.tar.gz: 9697f4bf452aaaa7cade45320c50d16b510c657074ba97513c5f8de9c51f6c49
3
+ metadata.gz: 6e1e1a54762132f92451d595938cb467b7b644dffc0817abe99209e1f92160f8
4
+ data.tar.gz: 297eec3d7fcee35d12e7f3509e8e3dfd4b8b3c52889c7570a79cd6a30f45eda4
5
5
  SHA512:
6
- metadata.gz: b28ef92375c7eef4d6c43fccb5e44105d653fb00e052edcf67316f8da13578ad7b39086b3799782592b38bf046760f8faa1238b92de293b83eb1e4a7c441413e
7
- data.tar.gz: dfd3891ae8d0303b88ac95268056addc3b4e03f862a5200166de9553b412eee78b77f42193f133f9dd340793b67928806e2e05451517585c2282fb7e4c871d1f
6
+ metadata.gz: 6d2c64622bd3b8465a749b5f6a8050d5fd1d5b623990f91421f91004c444baab12114964ded28d5ac0fa43fed56f3e893798feb31b00ab173d536e57fcfdfaa4
7
+ data.tar.gz: 02ee9d8742ffd3a7b16b8c23b8d4c4f58a8cb1b9db4d215ece4bf34de0c79830bd3417186b2d75dbbd48f6845d736361af7503f641e7faa16d139cbe193263d3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.0.4] - 2024-02-26
4
+ ### Changed
5
+ - changed default configuration values of `RedisQueuedLocks::Client` config;
6
+
3
7
  ## [0.0.3] - 2024-02-26
4
8
  ### Changed
5
9
  - Instrumentation events:
data/README.md CHANGED
@@ -2,6 +2,67 @@
2
2
 
3
3
  Distributed lock implementation with "lock acquisition queue" capabilities based on the Redis Database.
4
4
 
5
+ ## Configuration
6
+
7
+ ```ruby
8
+ redis_client = RedisClient.config.new_pool # NOTE: provide your own RedisClient instance
9
+
10
+ clinet = RedisQueuedLocks::Client.new(redis_client) do |config|
11
+ # (default: 3) (supports nil)
12
+ # - nil means "infinite retries" and you are only limited by the "try_to_lock_timeout" config;
13
+ config.retry_count = 3
14
+
15
+ # (milliseconds) (default: 200)
16
+ config.retry_delay = 200
17
+
18
+ # (milliseconds) (default: 50)
19
+ config.retry_jitter = 50
20
+
21
+ # (seconds) (supports nil)
22
+ # - nil means "no timeout" and you are only limited by "retry_count" config;
23
+ config.try_to_lock_timeout = 10
24
+
25
+ # (milliseconds) (default: 1)
26
+ # - expiration precision. affects the ttl (ttl + precision);
27
+ config.exp_precision = 1
28
+
29
+ # (milliseconds) (default: 5_000)
30
+ # - lock's time to live
31
+ config.default_lock_ttl = 5_000
32
+
33
+ # (seconds) (default: 15)
34
+ # - lock request timeout. after this timeout your lock request in queue will be requeued;
35
+ config.default_queue_ttl = 15
36
+
37
+ # (default: 100)
38
+ # - how many items will be released at a time in RedisQueuedLocks::Client#clear_locks logic;
39
+ # - affects the performancs capabilites (redis, rubyvm);
40
+ config.lock_release_batch_size = 100
41
+
42
+ # (default: RedisQueuedLocks::Instrument::VoidNotifier)
43
+ # - instrumentation layer;
44
+ # - you can provde your own instrumenter with `#notify(event, payload = {})`
45
+ # - event: <string> requried;
46
+ # - payload: <hash> requried;
47
+ # - disabled by default via VoidNotifier;
48
+ config.instrumenter = RedisQueuedLocks::Instrument::ActiveSupport
49
+ end
50
+ ```
51
+
52
+ ## Usage
53
+
54
+ ```ruby
55
+ redis_clinet = RedisClient.config.new_pool # NOTE: provide your ounw RedisClient instance
56
+ rq_lock = RedisQueuedLocks::Client.new(redis_client) do |config|
57
+ # NOTE: some your application-related configs
58
+ end
59
+ ```
60
+
61
+ - `#lock`
62
+ - `#lock!`
63
+ - `#unlock`
64
+ - `#clear_locks`
65
+
5
66
  ## Instrumentation events
6
67
 
7
68
  - `"redis_queued_locks.lock_obtained"`
@@ -32,6 +93,6 @@ Distributed lock implementation with "lock acquisition queue" capabilities based
32
93
  - `"redis_queued_locks.explicit_all_locks_release"`
33
94
  - an event signalizes about the explicit all locks release (invoked via `RedisQueuedLock#clear_locks`);
34
95
  - payload:
35
- - `rel_time` - `float`/`milliseconds` - time spent on the lock release;
96
+ - `rel_time` - `float`/`milliseconds` - time spent on "realese all locks" operation;
36
97
  - `at` - `integer`/`epoch` - the time when the operation has ended;
37
98
  - `rel_keys` - `integer` - released redis keys count (`released queu keys` + `released lock keys`);
@@ -10,10 +10,10 @@ class RedisQueuedLocks::Client
10
10
  setting :retry_count, 3
11
11
  setting :retry_delay, 200 # NOTE: milliseconds
12
12
  setting :retry_jitter, 50 # NOTE: milliseconds
13
- setting :default_timeout, 10 # NOTE: seconds
13
+ setting :try_to_lock_timeout, 10 # NOTE: seconds
14
14
  setting :exp_precision, 1 # NOTE: milliseconds
15
15
  setting :default_lock_ttl, 5_000 # NOTE: milliseconds
16
- setting :default_queue_ttl, 30 # NOTE: seconds
16
+ setting :default_queue_ttl, 15 # NOTE: seconds
17
17
  setting :lock_release_batch_size, 100
18
18
  setting :instrumenter, RedisQueuedLocks::Instrument::VoidNotifier
19
19
 
@@ -23,7 +23,7 @@ class RedisQueuedLocks::Client
23
23
  validate('retry_count') { |val| val == nil || (val.is_a?(::Integer) && val >= 0) }
24
24
  validate('retry_delay', :integer)
25
25
  validate('retry_jitter', :integer)
26
- validate('default_timeout', :integer)
26
+ validate('try_to_lock_timeout') { |val| val == nil || (val.is_a?(::Integer) && val >= 0) }
27
27
  validate('exp_precision', :integer)
28
28
  validate('default_lock_tt', :integer)
29
29
  validate('default_queue_ttl', :integer)
@@ -86,7 +86,7 @@ class RedisQueuedLocks::Client
86
86
  thread_id: RedisQueuedLocks::Resource.get_thread_id,
87
87
  ttl: config[:default_lock_ttl],
88
88
  queue_ttl: config[:default_queue_ttl],
89
- timeout: config[:default_timeout],
89
+ timeout: config[:try_to_lock_timeout],
90
90
  retry_count: config[:retry_count],
91
91
  retry_delay: config[:retry_delay],
92
92
  retry_jitter: config[:retry_jitter],
@@ -4,6 +4,7 @@ module RedisQueuedLocks
4
4
  # @return [String]
5
5
  #
6
6
  # @api public
7
- # @since 0.0.3
8
- VERSION = '0.0.3'
7
+ # @since 0.0.1
8
+ # @version 0.0.4
9
+ VERSION = '0.0.4'
9
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rustam Ibragimov