radiator 0.2.3rc2 → 0.2.3rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +7 -0
- data/lib/radiator/api.rb +91 -15
- data/lib/radiator/stream.rb +5 -1
- data/lib/radiator/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e78f81905adcd6e53025310e30ad7565de743621
|
4
|
+
data.tar.gz: 950ee3b476e2f2effd2fb46227b7d3e2f4febf21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67c4da518dd163f3d2b9b50f7c01bff39ded3ee0040f639a1024a39537d55e291675c558b447af553167fad97e796d44d9ba5a3836bf5f9b753eeab36dbaf0b4
|
7
|
+
data.tar.gz: 3304790b68d3c98ff2bc6b2331732802caf150d7330a0789b98a844096606774a9ee84c9e23fcdfdc0acf0e4675f6537cf19f89edceb9952345de43bab97336d
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
radiator (0.2.
|
4
|
+
radiator (0.2.3rc3)
|
5
5
|
bitcoin-ruby (= 0.0.10)
|
6
6
|
ffi (= 1.9.18)
|
7
7
|
hashie (~> 3.5, >= 3.5.5)
|
@@ -28,7 +28,7 @@ GEM
|
|
28
28
|
multipart-post (>= 1.2, < 3)
|
29
29
|
ffi (1.9.18)
|
30
30
|
hashdiff (0.3.4)
|
31
|
-
hashie (3.5.
|
31
|
+
hashie (3.5.6)
|
32
32
|
json (1.8.6)
|
33
33
|
little-plugger (1.1.4)
|
34
34
|
logging (2.2.2)
|
data/README.md
CHANGED
@@ -9,6 +9,13 @@
|
|
9
9
|
|
10
10
|
Radiator is an API Client for interaction with the STEEM network using Ruby.
|
11
11
|
|
12
|
+
#### Fixes in v0.2.3
|
13
|
+
|
14
|
+
* Added low-level support for persistence and retrying API requests.
|
15
|
+
* Now using exponential back-off for retries.
|
16
|
+
* Detecting presence of `transaction_ids` (if enabled by the node).
|
17
|
+
* Default for `Hashie` warnings now go to `/dev/null`, where they belong.
|
18
|
+
|
12
19
|
#### Fixes in v0.2.2
|
13
20
|
|
14
21
|
* Gem updates
|
data/lib/radiator/api.rb
CHANGED
@@ -14,8 +14,9 @@ module Radiator
|
|
14
14
|
@debug = !!options[:debug]
|
15
15
|
@net_http_persistent_enabled = true
|
16
16
|
@logger = options[:logger] || Radiator.logger
|
17
|
+
@hashie_logger = options[:hashie_logger] || Logger.new('/dev/null')
|
17
18
|
|
18
|
-
Hashie.logger = @
|
19
|
+
Hashie.logger = @hashie_logger
|
19
20
|
@method_names = nil
|
20
21
|
end
|
21
22
|
|
@@ -107,14 +108,68 @@ module Radiator
|
|
107
108
|
id: rpc_id,
|
108
109
|
method: "call"
|
109
110
|
}
|
110
|
-
|
111
|
-
response = request(options)
|
112
111
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
112
|
+
loop do
|
113
|
+
begin
|
114
|
+
response = request(options)
|
115
|
+
|
116
|
+
if !!response
|
117
|
+
case response.code
|
118
|
+
when '200'
|
119
|
+
response = JSON[response.body]
|
120
|
+
|
121
|
+
return Hashie::Mash.new(response)
|
122
|
+
when '400'
|
123
|
+
@logger.warn('Code 400: Bad Request, retrying ...')
|
124
|
+
backoff
|
125
|
+
redo
|
126
|
+
when '502'
|
127
|
+
@logger.warn('Code 502: Bad Gateway, retrying ...')
|
128
|
+
backoff
|
129
|
+
redo
|
130
|
+
when '503'
|
131
|
+
@logger.warn('Code 503: Service Unavailable, retrying ...')
|
132
|
+
backoff
|
133
|
+
redo
|
134
|
+
when '504'
|
135
|
+
@logger.warn('Code 504: Gateway Timeout, retrying ...')
|
136
|
+
backoff
|
137
|
+
redo
|
138
|
+
else
|
139
|
+
ap "Unknown code #{response.code}, retrying ..."
|
140
|
+
backoff
|
141
|
+
ap response
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
@logger.error("No response.")
|
146
|
+
break
|
147
|
+
rescue Errno::ECONNREFUSED => e
|
148
|
+
@logger.warn('Connection refused, retrying ...')
|
149
|
+
backoff
|
150
|
+
redo
|
151
|
+
rescue Errno::EADDRNOTAVAIL => e
|
152
|
+
@logger.warn('Node not available, retrying ...')
|
153
|
+
backoff
|
154
|
+
redo
|
155
|
+
rescue Net::ReadTimeout => e
|
156
|
+
@logger.warn('Node read timeout, retrying ...')
|
157
|
+
backoff
|
158
|
+
redo
|
159
|
+
rescue Net::OpenTimeout => e
|
160
|
+
@logger.warn('Node timeout, retrying ...')
|
161
|
+
backoff
|
162
|
+
redo
|
163
|
+
rescue RangeError => e
|
164
|
+
@logger.warn('Range Error, retrying ...')
|
165
|
+
backoff
|
166
|
+
redo
|
167
|
+
rescue => e
|
168
|
+
puts "Unknown exception from request ..."
|
169
|
+
backoff
|
170
|
+
ap e
|
171
|
+
end
|
172
|
+
end # loop
|
118
173
|
end
|
119
174
|
|
120
175
|
def shutdown
|
@@ -152,16 +207,20 @@ module Radiator
|
|
152
207
|
end
|
153
208
|
end
|
154
209
|
|
210
|
+
def post_request
|
211
|
+
Net::HTTP::Post.new uri.request_uri, 'Content-Type' => 'application/json'
|
212
|
+
end
|
213
|
+
|
155
214
|
def request(options)
|
156
215
|
if !!@net_http_persistent_enabled
|
157
216
|
begin
|
158
|
-
request =
|
217
|
+
request = post_request
|
159
218
|
request.body = JSON[options]
|
160
219
|
|
161
220
|
if (response = http.request(uri, request)).kind_of? Net::HTTPSuccess
|
162
221
|
return response
|
163
222
|
else
|
164
|
-
@logger.warn "Unexpeced response: #{response}"
|
223
|
+
@logger.warn "Unexpeced response: #{response.inspect}; temporarily falling back to non-persistent-http"
|
165
224
|
end
|
166
225
|
rescue Net::HTTP::Persistent::Error => e
|
167
226
|
@logger.warn "Unable to perform request: #{request} :: #{e}: #{e.backtrace}"
|
@@ -171,12 +230,29 @@ module Radiator
|
|
171
230
|
end
|
172
231
|
|
173
232
|
unless @net_http_persistent_enabled
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
request =
|
233
|
+
non_persistent_http = Net::HTTP.new(uri.host, uri.port)
|
234
|
+
non_persistent_http.use_ssl = true
|
235
|
+
non_persistent_http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
236
|
+
request = post_request
|
178
237
|
request.body = JSON[options]
|
179
|
-
|
238
|
+
|
239
|
+
# Try to go back to http persistent on next request.
|
240
|
+
@net_http_persistent_enabled = true
|
241
|
+
|
242
|
+
non_persistent_http.request(request)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
def backoff
|
247
|
+
@backoff_at ||= Time.now
|
248
|
+
@backoff_sleep ||= 0.01
|
249
|
+
|
250
|
+
@backoff_sleep *= 2
|
251
|
+
sleep @backoff_sleep
|
252
|
+
|
253
|
+
if Time.now - @backoff_at > 300
|
254
|
+
@backoff_at = nil
|
255
|
+
@backoff_sleep = nil
|
180
256
|
end
|
181
257
|
end
|
182
258
|
end
|
data/lib/radiator/stream.rb
CHANGED
@@ -140,7 +140,11 @@ module Radiator
|
|
140
140
|
return _transactions unless !!block
|
141
141
|
|
142
142
|
_transactions.each_with_index do |transaction, index|
|
143
|
-
|
143
|
+
trx_id = if !!b['transaction_ids']
|
144
|
+
b['transaction_ids'][index]
|
145
|
+
end
|
146
|
+
|
147
|
+
yield transaction, trx_id
|
144
148
|
end
|
145
149
|
end
|
146
150
|
end
|
data/lib/radiator/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3rc3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Martin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -410,7 +410,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
410
410
|
version: 1.3.1
|
411
411
|
requirements: []
|
412
412
|
rubyforge_project:
|
413
|
-
rubygems_version: 2.
|
413
|
+
rubygems_version: 2.6.12
|
414
414
|
signing_key:
|
415
415
|
specification_version: 4
|
416
416
|
summary: STEEM RPC Ruby Client
|