restrainer 1.1.2 → 1.1.4

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 (6) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -0
  3. data/README.md +1 -0
  4. data/VERSION +1 -1
  5. data/lib/restrainer.rb +2 -2
  6. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c49c2e29f3d29970f0975f8219d99dc74a79668f263b5c923ab0eb2ff92f8fae
4
- data.tar.gz: 7af2876a48e9a34d4ff3aad0cd5fb7b12bc5e20c7ee2e875760a59276cc7c601
3
+ metadata.gz: ca06e87682a08740ba7079ec9d8be18e898c2faa91b6b701659d284c1f325aa6
4
+ data.tar.gz: 9dd88e76dfa96a9626c51ae0cf10fcb0685c92d52b1f026d32add3dcee7b16b9
5
5
  SHA512:
6
- metadata.gz: 23d0627b6b1cca6b1c8c84ffeb20c595570c2918db27c73ce0a4a9aa158f8cf4df67cdd331d2e3b001106185c8adacffd070b215e2f47ac69b013cee1f3d11c0
7
- data.tar.gz: c7fc3e5188fa06628d7ab0f5fb4b27b74db917bb95f32ca76875c40be1052237ce83e9018c4bde079e99c09c19514dc1825a2df765f62787c910733e32e4c3f5
6
+ metadata.gz: d89b85954d32b68c7881179f6168666a896cae97ce8881c9e53c67a91c8d780ca38b7656c2245d76f317420c9c308a15a9204f45750b266078ceac0967c7322d
7
+ data.tar.gz: 60da5291b9936f94d144b4c1ba3db465c4587a479bc62ff0ff9bcd01a48200761e3f8bfa855d413e923eb7be1ddb1b941cd80ff11539f76a7840d64e33e79abf
data/CHANGELOG.md CHANGED
@@ -4,9 +4,22 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## 1.1.4
8
+
9
+ ### Removed
10
+
11
+ - Removed unimplemented method stub.
12
+
13
+ ## 1.1.3
14
+
15
+ ### Added
16
+
17
+ - Support for using fractional seconds in the lock timeout.
18
+
7
19
  ## 1.1.2
8
20
 
9
21
  ### Changed
22
+
10
23
  - Redis instance will now default to a Redis instance with the default options
11
24
  instead of throwing an error if it was not set.
12
25
  - Minumum Ruby version set to 2.5
@@ -14,20 +27,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
27
  ## 1.1.1
15
28
 
16
29
  ### Fixed
30
+
17
31
  - Circular reference warning
18
32
 
19
33
  ## 1.1.0
20
34
 
21
35
  ### Added
36
+
22
37
  - Expose manually locking and unlocking processes.
23
38
  - Allow passing in a redis connection in the constructor.
24
39
 
25
40
  ## 1.0.1
26
41
 
27
42
  ### Fixed
43
+
28
44
  - Use Lua script to avoid race conditions and ensure no extra processes slip through.
29
45
 
30
46
  ## 1.0.0
31
47
 
32
48
  ### Added
49
+
33
50
  - Initial release.
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  [![Continuous Integration](https://github.com/bdurand/restrainer/actions/workflows/continuous_integration.yml/badge.svg)](https://github.com/bdurand/restrainer/actions/workflows/continuous_integration.yml)
2
2
  [![Regression Test](https://github.com/bdurand/restrainer/actions/workflows/regression_test.yml/badge.svg)](https://github.com/bdurand/restrainer/actions/workflows/regression_test.yml)
3
3
  [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
4
+ [![Gem Version](https://badge.fury.io/rb/restrainer.svg)](https://badge.fury.io/rb/restrainer)
4
5
 
5
6
  This gem provides a method of throttling calls across processes that can be very useful if you have to call an external service with limited resources.
6
7
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.2
1
+ 1.1.4
data/lib/restrainer.rb CHANGED
@@ -38,7 +38,7 @@ class Restrainer
38
38
  -- Success so add to the list and set a global expiration so the list cleans up after itself.
39
39
  if process_count < limit then
40
40
  redis.call('zadd', sorted_set, now, process_id)
41
- redis.call('expire', sorted_set, ttl)
41
+ redis.call('pexpire', sorted_set, math.ceil(ttl * 1000))
42
42
  end
43
43
 
44
44
  -- Return the number of processes running before the process was added.
@@ -209,7 +209,7 @@ class Restrainer
209
209
  end
210
210
 
211
211
  begin
212
- redis.evalsha(sha1, [], [key, process_id, throttle_limit, @timeout, Time.now.to_i])
212
+ redis.evalsha(sha1, [], [key, process_id, throttle_limit, @timeout, Time.now.to_f])
213
213
  rescue Redis::CommandError => e
214
214
  if e.message.include?("NOSCRIPT")
215
215
  sha1 = redis.script(:load, ADD_PROCESS_SCRIPT)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restrainer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Durand
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-11 00:00:00.000000000 Z
11
+ date: 2023-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  requirements: []
73
- rubygems_version: 3.4.12
73
+ rubygems_version: 3.4.20
74
74
  signing_key:
75
75
  specification_version: 4
76
76
  summary: Code for throttling workloads so as not to overwhelm external services