rate_limit-htb 0.1.0 → 0.1.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/lib/rate_limit/htb.rb +3 -3
- data/lib/rate_limit/htb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '093b0c2494faa00447a189c53ada0a6d2d3ded74'
|
4
|
+
data.tar.gz: b24d7b92107c7889a6d0e7ae0688d9b4eae4a410
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d50ea8b4df23a088a1fc0f1df4a2b2efef09b60007a0bfd3445711399b0ef11d7bb9c245191544920f18e4393526f448a752dbee52e82fcdf8de830e74a7daf
|
7
|
+
data.tar.gz: 68fcf7029d1302aefd6a6b18becf1874105e7b2391b7722f22f012dc042abe8847d660231754285fb956e849ee6e87a1be385be5078d64585fa2ebb0596cd988
|
data/lib/rate_limit/htb.rb
CHANGED
@@ -53,7 +53,7 @@ module RateLimit
|
|
53
53
|
#
|
54
54
|
def initialize(rate, parent = nil)
|
55
55
|
@lock = Monitor.new
|
56
|
-
@rate = rate
|
56
|
+
@rate = rate || 0
|
57
57
|
@bucket_size = rate
|
58
58
|
@parent = parent
|
59
59
|
@tokens = rate
|
@@ -87,8 +87,8 @@ module RateLimit
|
|
87
87
|
# Try to take amount tokens from this bucket or wait for the tokens to replenish
|
88
88
|
# do this until we could get the amount of tokens we wanted
|
89
89
|
until take amount
|
90
|
-
duration = amount.to_f /
|
91
|
-
puts "sleeping for #{duration}"
|
90
|
+
duration = amount.to_f / rate # rate is a method
|
91
|
+
#puts "sleeping for #{duration}"
|
92
92
|
sleep duration
|
93
93
|
end
|
94
94
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rate_limit-htb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominic Althaus
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|