redis-throttle 2.0.0 → 2.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6dbef2b5249fc1cd8ff9c199e00b11b98dafa0ec8f0a707e9da8af4c5fa3ed1d
4
- data.tar.gz: 2a8ddfd1fe58e6f9a3e63cb219ab42450518f804cce806e7778aaca251563cb1
3
+ metadata.gz: cd088fd2ee696ff54e4dd8bd1257963beeabf911a7ee19ca48aa5f622828ee2b
4
+ data.tar.gz: bac4008e1ac109552e9a9dd410868f52c7a56948a1557f2a389d357d76345c12
5
5
  SHA512:
6
- metadata.gz: 74c91479a17ea0759cb6d9a9bcf78c27d1454339a3dca5678cb90aa28c582ed6f11f5d825ff38401a51e9a039728f3d4494887466674f2c29aae4615b376af41
7
- data.tar.gz: 4e299f8ae32084daf1c5941629601ba48d4af09d5cec9504421e05a462e0be1a24131929c56c3913f5edf70b4aa53a3a8a57d0d72d90a494193695d8fffb3db5
6
+ metadata.gz: 33f05576f3a282c8b552ff0d96903dee2f207691efa47b5de5c80b3ac011075037f6cab19d10a9b60283b5f0eb5173282d5e05c4706fd20764ae45f59f34d1d3
7
+ data.tar.gz: 69e178cf920b7fb900acdb1edd6d8e968dc3f31c574c3a356773055b6507b0799f811952897f2df8746817f1437f9e0443e8f555a614b8024d20e565ccf15ff9
data/README.adoc CHANGED
@@ -24,7 +24,7 @@ Or install it yourself as:
24
24
  # gone (as if process died, or by any other reason did not called `#release`):
25
25
  concurrency = RedisThrottle.concurrency(:bucket_name,
26
26
  limit: 1,
27
- :ttl => 10
27
+ ttl: 10
28
28
  )
29
29
 
30
30
  concurrency.acquire(redis, token: "abc") # => "abc"
@@ -41,7 +41,7 @@ concurrency.acquire(redis, token: "xyz") # => "xyz"
41
41
  ----
42
42
  # Allow 1 calls per 10 seconds:
43
43
  rate_limit = RedisThrottle.rate_limit(:bucket_name,
44
- :limit => 1,
44
+ limit: 1,
45
45
  period: 10
46
46
  )
47
47
 
@@ -41,7 +41,7 @@ class RedisThrottle
41
41
  # @param token [String]
42
42
  # @return [void]
43
43
  def release(strategies:, token:)
44
- execute(:RELEASE, to_params(strategies.grep(Concurrency)) << :TOKEN << token)
44
+ execute(:RELEASE, to_params(strategies) << :TOKEN << token)
45
45
  end
46
46
 
47
47
  # @param strategies [Enumerable<Concurrency, RateLimit>]
@@ -95,19 +95,23 @@ class RedisThrottle
95
95
  end
96
96
  end
97
97
 
98
- def to_params(strategies)
99
- result = []
98
+ def to_params(strategies) # rubocop:disable Metrics/MethodLength
99
+ params = []
100
100
 
101
101
  strategies.each do |strategy|
102
102
  case strategy
103
103
  when Concurrency
104
- result << "concurrency" << strategy.bucket << strategy.limit << strategy.ttl
104
+ params.push("concurrency", strategy.bucket, strategy.limit, strategy.ttl)
105
105
  when RateLimit
106
- result << "rate_limit" << strategy.bucket << strategy.limit << strategy.period
106
+ params.push("rate_limit", strategy.bucket, strategy.limit, strategy.period)
107
+ else
108
+ raise TypeError, "invalid startegy: #{strategy.inspect}"
107
109
  end
108
110
  end
109
111
 
110
- result
112
+ raise ArgumentError, "missing strategies" if params.empty?
113
+
114
+ params
111
115
  end
112
116
  end
113
117
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  class RedisThrottle
4
4
  # Gem version.
5
- VERSION = "2.0.0"
5
+ VERSION = "2.0.1"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-throttle
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Zapparov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-10 00:00:00.000000000 Z
11
+ date: 2023-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -59,9 +59,9 @@ licenses:
59
59
  - MIT
60
60
  metadata:
61
61
  homepage_uri: https://gitlab.com/ixti/redis-throttle
62
- source_code_uri: https://gitlab.com/ixti/redis-throttle/tree/v2.0.0
62
+ source_code_uri: https://gitlab.com/ixti/redis-throttle/tree/v2.0.1
63
63
  bug_tracker_uri: https://gitlab.com/ixti/redis-throttle/issues
64
- changelog_uri: https://gitlab.com/ixti/redis-throttle/blob/v2.0.0/CHANGES.md
64
+ changelog_uri: https://gitlab.com/ixti/redis-throttle/blob/v2.0.1/CHANGES.md
65
65
  rubygems_mfa_required: 'true'
66
66
  post_install_message:
67
67
  rdoc_options: []