exp_retry 0.0.9 → 0.0.10

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
- SHA1:
3
- metadata.gz: 7fe5b3d98bd8df4bddc6cbbc7462edb69aaa662a
4
- data.tar.gz: 86ccee803485c0da30028d38390d2992f67da098
2
+ SHA256:
3
+ metadata.gz: 478f3730c0066f80c4299dfaab7e4da27fd681386e3ffc5bb97b3f9f67717e40
4
+ data.tar.gz: 78ccc9dbedcb20e4128d3327ae344e5fa2c6eaaf914a5a37ac4e337fc2c907e2
5
5
  SHA512:
6
- metadata.gz: 90b50f465637a0798f8e059cb4d52768f90733d6d541b2c5d504d47ce14b8fe1003bf8d632419da93931c981102581664559dca69b1eca8d5bff15199d928678
7
- data.tar.gz: 77fdf06fd4410596ac6c753b1cff31f4152c5e74f419245004fe0bcbf8270ac48fbf5ed4e89c294844de0ad477fd0445a21c437d71f77abcb4b2a5de3f50672d
6
+ metadata.gz: 6ec84ab84ca800bed992be7efdd5e21a7054b3d87f6855fbdd1b11845a755ee72d8cd4a91eaf0a4ce53b9192093697f25e45e6ddf7bf3bdca403167ae27576ff
7
+ data.tar.gz: d159d8dd4355a4447d50ef5f38f627022f3d25329f3c6d7e9cb71b636b76950d720e050473ac0be18dfede165a6596af58e02b944f38bf804f96949a7426cce8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- exp_retry (0.0.9)
4
+ exp_retry (0.0.10)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -39,4 +39,4 @@ DEPENDENCIES
39
39
  simplecov (~> 0.15, >= 0.15.1)
40
40
 
41
41
  BUNDLED WITH
42
- 1.16.4
42
+ 1.17.3
data/Readme.md CHANGED
@@ -61,3 +61,12 @@ ExpRetry.for(retries: 5, exception: [SpecificError, AnotherError]) do
61
61
  something_specific # errors will trigger up to 5 retries
62
62
  end
63
63
  ```
64
+
65
+ To display internal logging, run with the `verbose` flag:
66
+
67
+ ```ruby
68
+ ExpRetry.for(retries: 5, exception: SpecificError, verbose: true) do
69
+ something_generic # errors will surface immediately
70
+ something_specific # errors will trigger up to 5 retries
71
+ end
72
+ ```
data/exp-retry.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'exp_retry'
3
- s.version = '0.0.9'
4
- s.date = '2018-10-26'
3
+ s.version = '0.0.10'
4
+ s.date = '2019-06-15'
5
5
  s.summary = 'Exponential backoff retry'
6
6
  s.description = 'A simple exponential backoff retry wrapper.'
7
7
  s.homepage = 'http://rubygems.org/gems/exp_retry'
data/lib/exp_retry.rb CHANGED
@@ -2,13 +2,14 @@
2
2
 
3
3
  # Exponential backoff retry wrapper
4
4
  class ExpRetry
5
- def self.for(retries: 3, exception: StandardError)
6
- new(retries: retries, exception: exception).call { yield }
5
+ def self.for(retries: 3, exception: StandardError, verbose: false)
6
+ new(retries: retries, exception: exception, verbose: verbose).call { yield }
7
7
  end
8
8
 
9
- def initialize(retries: 3, exception: StandardError)
9
+ def initialize(retries: 3, exception: StandardError, verbose: false)
10
10
  @retries = retries
11
11
  @exception = exception
12
+ @verbose = verbose
12
13
  end
13
14
 
14
15
  def call
@@ -20,8 +21,8 @@ class ExpRetry
20
21
 
21
22
  private
22
23
 
23
- def check(e)
24
- retried > @retries ? raise(e) : delay(e)
24
+ def check(exception)
25
+ retried > @retries ? raise(exception) : delay(exception)
25
26
  end
26
27
 
27
28
  def retried
@@ -29,8 +30,10 @@ class ExpRetry
29
30
  @retried += 1
30
31
  end
31
32
 
32
- def delay(e)
33
- puts "*** #{e}. Retrying in #{2**@retried} seconds..."
33
+ def delay(exception)
34
+ output = "*** #{exception}. Retrying in #{2**@retried} seconds..."
35
+ output = '-' if @verbose
36
+ puts output
34
37
  sleep 2**@retried
35
38
  end
36
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exp_retry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-26 00:00:00.000000000 Z
11
+ date: 2019-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  requirements: []
110
110
  rubyforge_project:
111
- rubygems_version: 2.6.11
111
+ rubygems_version: 2.7.6
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: Exponential backoff retry