istox 0.1.113 → 0.1.114
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/lib/istox.rb +1 -0
- data/lib/istox/constants/error.rb +7 -0
- data/lib/istox/helpers/rate_limit.rb +22 -0
- data/lib/istox/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0fd11929f5853a08a199a47e6959dfc57dbbe45230656f0954af44cbb351890
|
4
|
+
data.tar.gz: 20ed7facb33b36e0d26cba19aa96a29eaeeafc3c004b2c484705e84072613110
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f601579de1c82b4aefc82c81031d7e31eb6e268326376a77aa5eae7931be6299354802bd3e91809c4304634b9ce9451f3e756f04ab13d0416115881d15cf7e9
|
7
|
+
data.tar.gz: 06635e08d320336b4695de7f946d2fb0319e66d54d170aaa80a06005945c8f23cfbe0e2f33285edb92225b1d55d5e1536852d51fc5cc2d4cd68f9be22760f4ff
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
istox (0.1.
|
4
|
+
istox (0.1.113)
|
5
5
|
awesome_print
|
6
6
|
binding_of_caller
|
7
7
|
bunny (>= 2.12.0)
|
@@ -95,7 +95,7 @@ GEM
|
|
95
95
|
ffi (1.11.3)
|
96
96
|
globalid (0.4.2)
|
97
97
|
activesupport (>= 4.2.0)
|
98
|
-
google-protobuf (3.11.2)
|
98
|
+
google-protobuf (3.11.2-universal-darwin)
|
99
99
|
googleapis-common-protos-types (1.0.4)
|
100
100
|
google-protobuf (~> 3.0)
|
101
101
|
graphlient (0.3.7)
|
@@ -106,7 +106,7 @@ GEM
|
|
106
106
|
graphql-client (0.16.0)
|
107
107
|
activesupport (>= 3.0)
|
108
108
|
graphql (~> 1.8)
|
109
|
-
grpc (1.26.0)
|
109
|
+
grpc (1.26.0-universal-darwin)
|
110
110
|
google-protobuf (~> 3.8)
|
111
111
|
googleapis-common-protos-types (~> 1.0)
|
112
112
|
grpc-tools (1.26.0)
|
data/lib/istox.rb
CHANGED
@@ -85,6 +85,28 @@ module Istox
|
|
85
85
|
!exceeded?(subject, options)
|
86
86
|
end
|
87
87
|
|
88
|
+
# Check if next execution will cause the rate limit to be exceeded, raise error if exceeded
|
89
|
+
#
|
90
|
+
# @param [String] subject Subject to check
|
91
|
+
# @param [Hash] options Options hash
|
92
|
+
# @option options [Integer] :interval How far back to retrieve activity.
|
93
|
+
# @option options [Integer] :threshold Maximum number of actions
|
94
|
+
def limit!(subject, options = {})
|
95
|
+
add(subject)
|
96
|
+
raise ::Istox::RateLimitExceedError if exceeded?(subject, options)
|
97
|
+
end
|
98
|
+
|
99
|
+
# Check if next execution will cause the rate limit to be exceeded, return false if exceeded, else return true
|
100
|
+
#
|
101
|
+
# @param [String] subject Subject to check
|
102
|
+
# @param [Hash] options Options hash
|
103
|
+
# @option options [Integer] :interval How far back to retrieve activity.
|
104
|
+
# @option options [Integer] :threshold Maximum number of actions
|
105
|
+
def limit?(subject, options = {})
|
106
|
+
add(subject)
|
107
|
+
within_bounds?(subject, options)
|
108
|
+
end
|
109
|
+
|
88
110
|
# Execute a block once the rate limit is within bounds
|
89
111
|
# *WARNING* This will block the current thread until the rate limit is within bounds.
|
90
112
|
#
|
data/lib/istox/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: istox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.114
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Siong Leng
|
@@ -373,6 +373,7 @@ files:
|
|
373
373
|
- bin/setup
|
374
374
|
- istox.gemspec
|
375
375
|
- lib/istox.rb
|
376
|
+
- lib/istox/constants/error.rb
|
376
377
|
- lib/istox/consumers/blockchain_status_handler.rb
|
377
378
|
- lib/istox/helpers/blockchain_service.rb
|
378
379
|
- lib/istox/helpers/bunny_boot.rb
|