istox 0.1.113 → 0.1.114

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 051bd3f64bac36e0344335c8d977aad2cbb7fc339bc0aa38bd6602718faaff74
4
- data.tar.gz: 56f242af8d6fa59be8a800a977ede487cab6e511fbf7fada1a105096c8a996e6
3
+ metadata.gz: f0fd11929f5853a08a199a47e6959dfc57dbbe45230656f0954af44cbb351890
4
+ data.tar.gz: 20ed7facb33b36e0d26cba19aa96a29eaeeafc3c004b2c484705e84072613110
5
5
  SHA512:
6
- metadata.gz: f0101e6728edd36b69ea6cdded9258feacc4f17fe79e0b7f5393c5210424b1925b8280a5a2289ba88a09020fb008a46477790171856ddfa046abc3d5a1a67af8
7
- data.tar.gz: f49243acb52c4865c5541b10a1093ac88efc4bb9673ade9d7d56f198de6fea99d6f90db71992001f9b384228ae517534ab0a7c7caea49a5fcc14d2006a10e6cb
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.112)
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
@@ -12,6 +12,7 @@ module Istox
12
12
  end
13
13
  end
14
14
 
15
+ require 'istox/constants/error'
15
16
  require 'istox/helpers/logger'
16
17
  require 'istox/interfaces/chainhub/transaction'
17
18
  require 'istox/helpers/publisher'
@@ -0,0 +1,7 @@
1
+ module Istox
2
+ class IstoxError < StandardError
3
+ end
4
+
5
+ class RateLimitExceedError < IstoxError
6
+ end
7
+ end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Istox
2
- VERSION = '0.1.113'.freeze
2
+ VERSION = '0.1.114'.freeze
3
3
  end
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.113
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