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 +4 -4
- data/README.adoc +2 -2
- data/lib/redis_throttle/api.rb +10 -6
- data/lib/redis_throttle/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd088fd2ee696ff54e4dd8bd1257963beeabf911a7ee19ca48aa5f622828ee2b
|
4
|
+
data.tar.gz: bac4008e1ac109552e9a9dd410868f52c7a56948a1557f2a389d357d76345c12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
:
|
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
|
-
:
|
44
|
+
limit: 1,
|
45
45
|
period: 10
|
46
46
|
)
|
47
47
|
|
data/lib/redis_throttle/api.rb
CHANGED
@@ -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
|
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
|
-
|
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
|
-
|
104
|
+
params.push("concurrency", strategy.bucket, strategy.limit, strategy.ttl)
|
105
105
|
when RateLimit
|
106
|
-
|
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
|
-
|
112
|
+
raise ArgumentError, "missing strategies" if params.empty?
|
113
|
+
|
114
|
+
params
|
111
115
|
end
|
112
116
|
end
|
113
117
|
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.
|
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-
|
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.
|
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.
|
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: []
|