excess_flow 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/excess_flow/constants.rb +1 -1
- data/lib/excess_flow/fixed_window_strategy.rb +5 -1
- data/lib/excess_flow/sliding_window_strategy.rb +5 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba273741f4b6cb0d38335b7ee7eba8c9283604ce30e2e4463c3dca614ec67f2c
|
4
|
+
data.tar.gz: 44a3a1ef66b0163008e8a62a1c250ac565d7e59e155eab3e18b1f1b4014c8e0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4aacbfcf9b81aeb05024920ab3cbd5e1e2aeb70ce60c65b5cbc7fbea918415609f4dd16067955d1e0d7939f3fec39fa2ef2455709b63baf8dc63a205800c9d6f
|
7
|
+
data.tar.gz: 9d357b9e4622e08dc348c478b6980ddb2d238e4ef6e69b2900996361e35d1f0ac3d189bb40c92f6ee5db62577e4d055f679d4fb91a63bd688f0c2c2dc91ca815
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -46,8 +46,12 @@ module ExcessFlow
|
|
46
46
|
@current_requests ||= ExcessFlow.redis { |r| r.get(configuration.counter_key) }.to_i
|
47
47
|
end
|
48
48
|
|
49
|
+
def current_ttl
|
50
|
+
@current_ttl ||= ExcessFlow.redis { |r| r.ttl(configuration.counter_key) }.to_i
|
51
|
+
end
|
52
|
+
|
49
53
|
def start_expiration_window
|
50
|
-
return unless
|
54
|
+
return unless current_ttl.negative?
|
51
55
|
|
52
56
|
ExcessFlow.redis { |r| r.expire(configuration.counter_key, configuration.ttl) }
|
53
57
|
end
|
@@ -60,12 +60,16 @@ module ExcessFlow
|
|
60
60
|
@current_requests ||= ExcessFlow.redis { |r| r.zcount(configuration.counter_key, '-inf', '+inf') }
|
61
61
|
end
|
62
62
|
|
63
|
+
def current_ttl
|
64
|
+
@current_ttl ||= ExcessFlow.redis { |r| r.ttl(configuration.counter_key) }.to_i
|
65
|
+
end
|
66
|
+
|
63
67
|
def current_timestamp
|
64
68
|
@current_timestamp ||= (Time.now.to_f * 100_000).to_i
|
65
69
|
end
|
66
70
|
|
67
71
|
def start_expiration_window
|
68
|
-
return if
|
72
|
+
return if current_ttl.negative?
|
69
73
|
|
70
74
|
ExcessFlow.redis { |r| r.expire(configuration.counter_key, configuration.ttl) }
|
71
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excess_flow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ConvertKit, LLC
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: connection_pool
|