stellar_spectrum 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9bde5c4526ef6395789a0f36643e1b172f2ee39b27d92783ae33c90f361ccccf
4
- data.tar.gz: 4fabffb86d4194e6c278c91aabbd57027561101f025e91c0760d01f59ed95c23
3
+ metadata.gz: a03e0f25c992788e8b3f4b13713ab69d23331e3194bd5e61f2e53550c3226df9
4
+ data.tar.gz: cceb241d7e1f988857ee682e81f1a56f41f02af198d200d685f378a7e8c1594a
5
5
  SHA512:
6
- metadata.gz: e59d089d618d4957a4b1c1f853b329f484ccf50289b59c811af883720996fdab88a6d2856318971b5fcaecc1678d164d5e33ef349199cb2be677565ac7f59fa6
7
- data.tar.gz: 4546b8bd18f5f460d761d687d93a95e8423d5105b2dff88775b0e1bf534b7d353eb16526daefa40ae166522520219225c7bc3db7658e8422872f11dbaecb8054
6
+ metadata.gz: bac931885f03c9ee063ab57e164c642f707e5d5498eef5ba3db341692f9db17b0aceb161b7f240a3434a5385969d59dfa34d2524cbe0a4087026ae1730ba91a5
7
+ data.tar.gz: 1aec0f8499eddc6698df89fdf6792a7135d288d30029706bad79a782dac7c1a8bb6dbc81738a01cbeb32cb57de6a5efd6b739af2d117bc705dec1cfb64a26361
data/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [1.3.0] - 2019-01-29
8
+ ### Fixed
9
+ - Do not retry forever (and hitting the stack limit)
10
+
11
+ ### Added
12
+ - `max_tries` configuration setting
13
+
7
14
  ## [1.2.0] - 2019-01-18
8
15
  ### Added
9
16
  - Retry calls to Stellar horizon API regardless of the type of error code it receives.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stellar_spectrum (1.2.0)
4
+ stellar_spectrum (1.3.0)
5
5
  activesupport
6
6
  gem_config
7
7
  light-service
@@ -38,7 +38,7 @@ GEM
38
38
  net-http-digest_auth (~> 1.4)
39
39
  faraday_hal_middleware (0.1.0)
40
40
  faraday_middleware (~> 0.9)
41
- faraday_middleware (0.12.2)
41
+ faraday_middleware (0.13.0)
42
42
  faraday (>= 0.7.4, < 1.0)
43
43
  ffi (1.10.0)
44
44
  gem_config (0.3.1)
@@ -50,7 +50,7 @@ GEM
50
50
  faraday_middleware
51
51
  net-http-digest_auth
52
52
  uri_template
53
- i18n (1.5.2)
53
+ i18n (1.5.3)
54
54
  concurrent-ruby (~> 1.0)
55
55
  light-service (0.11.0)
56
56
  activesupport (>= 3.0)
@@ -66,7 +66,7 @@ GEM
66
66
  pry (~> 0.10)
67
67
  public_suffix (3.0.3)
68
68
  rake (10.5.0)
69
- rbnacl (6.0.0)
69
+ rbnacl (6.0.1)
70
70
  ffi
71
71
  redis (4.1.0)
72
72
  rspec (3.8.0)
@@ -7,6 +7,7 @@ require "redis"
7
7
  require "active_support/core_ext/hash/except"
8
8
  require "active_support/core_ext/object/blank"
9
9
  require 'active_support/core_ext/integer/inflections'
10
+ require "stellar_spectrum/services/fibo"
10
11
  require "stellar_spectrum/services/get_available_channels"
11
12
  require "stellar_spectrum/services/get_channel_account_info"
12
13
  require "stellar_spectrum/services/get_channel_accounts"
@@ -32,11 +33,16 @@ module StellarSpectrum
32
33
 
33
34
  include GemConfig::Base
34
35
 
36
+ # 17 tries means this gem will try up to about 17 times before
37
+ # giving up, and letting the error bubble up
38
+ DEFAULT_MAX_TRIES = 17.freeze
39
+
35
40
  with_configuration do
36
41
  has :redis_url, classes: [NilClass, String]
37
42
  has :seeds, classes: [NilClass, Array]
38
43
  has :horizon_url, classes: [NilClass, String]
39
44
  has :logger
45
+ has :max_tries, classes: [Integer], default: DEFAULT_MAX_TRIES
40
46
  end
41
47
 
42
48
  def self.new(*args)
@@ -0,0 +1,15 @@
1
+ module StellarSpectrum
2
+ class Fibo
3
+
4
+ def self.call(n)
5
+ return n if n <= 1
6
+
7
+ @cache ||= {}
8
+ cached_value = @cache[n]
9
+ return cached_value unless cached_value.nil?
10
+
11
+ @cache[n] = self.(n-1) + self.(n-2)
12
+ end
13
+
14
+ end
15
+ end
@@ -18,10 +18,9 @@ module StellarSpectrum
18
18
  ]
19
19
  expects *EXPECTS
20
20
  promises :send_asset_response
21
- WAIT_TIME_IN_SECONDS = 5
22
21
 
23
22
  executed do |c|
24
- sleep WAIT_TIME_IN_SECONDS
23
+ sleep Fibo.(c.tries)
25
24
 
26
25
  args = EXPECTS.each_with_object({}) do |attr, hash|
27
26
  hash[attr] = c.send(attr)
@@ -30,6 +30,8 @@ module StellarSpectrum
30
30
  sequence: c.next_sequence_number,
31
31
  )
32
32
  rescue Faraday::ClientError => e
33
+ fail if c.tries >= StellarSpectrum.configuration.max_tries
34
+
33
35
  Log.warn("Retrying SendingPayment::SendAsset - #{e.inspect}")
34
36
  retry_result = Retry.execute(
35
37
  stellar_client: c.stellar_client,
@@ -1,3 +1,3 @@
1
1
  module StellarSpectrum
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stellar_spectrum
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ramon Tayag
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-01-18 00:00:00.000000000 Z
12
+ date: 2019-01-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -175,6 +175,7 @@ files:
175
175
  - docker-compose.yml
176
176
  - lib/stellar_spectrum.rb
177
177
  - lib/stellar_spectrum/client.rb
178
+ - lib/stellar_spectrum/services/fibo.rb
178
179
  - lib/stellar_spectrum/services/get_available_channels.rb
179
180
  - lib/stellar_spectrum/services/get_channel_account_info.rb
180
181
  - lib/stellar_spectrum/services/get_channel_accounts.rb
@@ -221,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
222
  version: '0'
222
223
  requirements: []
223
224
  rubyforge_project:
224
- rubygems_version: 2.7.8
225
+ rubygems_version: 2.7.7
225
226
  signing_key:
226
227
  specification_version: 4
227
228
  summary: Use Stellar payment channels in Ruby with ease