prorate 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/prorate/rate_limit.lua +3 -2
- data/lib/prorate/throttle.rb +1 -1
- data/lib/prorate/version.rb +1 -1
- data/prorate.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 941127ba358ced7518e1c69224680aadb4beceac96127013f77f26dd8013619d
|
4
|
+
data.tar.gz: 9e517111477fc854e1404bedbd89126d0002f3d98386091180e757d9dcfdf992
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6478f0fb8c2df29254cae40e47ba5ffaa6bf09fce03543907edce681056e342eed6fdca57b4025449081c7c768f435ecb9e33cb2a76cc727500dd34b63c7b65c
|
7
|
+
data.tar.gz: 0e2a1376cd72013f9511b87a01143003c8ffe7a093004b9dbe13130008fef006e65452d1000e6998d997599f11120b883bca5f09eaeab5462b3eb6297f5e3cf7
|
data/lib/prorate/rate_limit.lua
CHANGED
@@ -31,7 +31,8 @@ local key_lifetime = math.ceil(max_bucket_capacity / leak_rate)
|
|
31
31
|
|
32
32
|
local blocked_until = redis.call("GET", block_key)
|
33
33
|
if blocked_until then
|
34
|
-
|
34
|
+
-- see https://redis.io/docs/manual/programmability/lua-api/ : floats should be returned as strings or they will be cast into integers
|
35
|
+
return {(tostring(tonumber(blocked_until) - now)), -1}
|
35
36
|
end
|
36
37
|
|
37
38
|
-- get current bucket level. The throttle key might not exist yet in which
|
@@ -49,7 +50,7 @@ if (new_bucket_level + n_tokens) <= max_bucket_capacity then
|
|
49
50
|
retval = {0, math.ceil(new_bucket_level)}
|
50
51
|
else
|
51
52
|
redis.call("SETEX", block_key, block_duration, now + block_duration)
|
52
|
-
retval = {block_duration,
|
53
|
+
retval = {tostring(block_duration), -1}
|
53
54
|
end
|
54
55
|
|
55
56
|
-- Save the new bucket level
|
data/lib/prorate/throttle.rb
CHANGED
@@ -95,7 +95,7 @@ module Prorate
|
|
95
95
|
block_for: @block_for,
|
96
96
|
n_tokens: n_tokens)
|
97
97
|
|
98
|
-
if
|
98
|
+
if bucket_level == -1
|
99
99
|
@logger.warn do
|
100
100
|
"Throttle %s exceeded limit of %d in %d seconds and is blocked for the next %d seconds" % [@name, @limit, @period, remaining_block_time]
|
101
101
|
end
|
data/lib/prorate/version.rb
CHANGED
data/prorate.gemspec
CHANGED
@@ -34,5 +34,5 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_development_dependency "rspec", "~> 3.0"
|
35
35
|
spec.add_development_dependency 'wetransfer_style', '0.6.5'
|
36
36
|
spec.add_development_dependency 'yard', '~> 0.9'
|
37
|
-
spec.add_development_dependency 'pry', '~> 0.
|
37
|
+
spec.add_development_dependency 'pry', '~> 0.14.2'
|
38
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prorate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julik Tarkhanov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
117
|
+
version: 0.14.2
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
124
|
+
version: 0.14.2
|
125
125
|
description: Can be used to implement all kinds of throttles
|
126
126
|
email:
|
127
127
|
- me@julik.nl
|
@@ -173,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
173
|
- !ruby/object:Gem::Version
|
174
174
|
version: '0'
|
175
175
|
requirements: []
|
176
|
-
rubygems_version: 3.0.
|
176
|
+
rubygems_version: 3.0.3.1
|
177
177
|
signing_key:
|
178
178
|
specification_version: 4
|
179
179
|
summary: Time-restricted rate limiter using Redis
|