evt-retry 0.1.1.1 → 0.1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/retry/controls/dependency.rb +15 -0
- data/lib/retry/controls/error.rb +2 -2
- data/lib/retry/controls/receiver.rb +14 -0
- data/lib/retry/controls.rb +2 -0
- data/lib/retry/retry.rb +23 -14
- data/lib/retry/substitute.rb +14 -0
- data/lib/retry/telemetry.rb +23 -0
- data/lib/retry.rb +4 -0
- metadata +35 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ead5a0d5b48258bfa2e98064a2c647fa6acf795149b68ec7ea73d94756b5b97f
|
4
|
+
data.tar.gz: 1d9aae6ee82c7dd3d38f3f102abc9a595e8eddd25fd0ff99a67d13b9b1610fee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c2af64e361bd3c9d50cedda46d6cdd598c28340c1aa1ab5b6141faf2db2070d48544f883d1a3133dc60b7494b3003cc9b7497595ef62a9746980a1a1f8a3fce
|
7
|
+
data.tar.gz: 532d792246a1b2980e57f2dafc07ea42db7f0c5cf63e752f25beb565211398b6a656b5cb20e93c4da90a3b45833aaa9a244977df7c2378d078fbf3f4892a8210
|
data/lib/retry/controls/error.rb
CHANGED
data/lib/retry/controls.rb
CHANGED
data/lib/retry/retry.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
class Retry
|
2
|
-
|
3
|
-
|
4
|
-
def millisecond_intervals
|
5
|
-
@millisecond_intervals ||= [0].to_enum
|
6
|
-
end
|
7
|
-
attr_writer :millisecond_intervals
|
2
|
+
include ::Telemetry::Dependency
|
3
|
+
extend Retry::Telemetry::Register
|
8
4
|
|
9
5
|
def action_executed(&action)
|
10
6
|
unless action.nil?
|
@@ -15,25 +11,35 @@ class Retry
|
|
15
11
|
end
|
16
12
|
attr_writer :action_executed
|
17
13
|
|
18
|
-
def self.build
|
19
|
-
|
20
|
-
|
14
|
+
def self.build
|
15
|
+
new
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.configure(receiver, attr_name: nil)
|
19
|
+
attr_name ||= :rtry
|
20
|
+
instance = build
|
21
|
+
receiver.public_send("#{attr_name}=", instance)
|
21
22
|
instance
|
22
23
|
end
|
23
24
|
|
24
25
|
def self.call(*errors, millisecond_intervals: nil, &action)
|
25
|
-
instance = build
|
26
|
-
instance.(&action)
|
26
|
+
instance = build
|
27
|
+
instance.(errors, millisecond_intervals: millisecond_intervals, &action)
|
27
28
|
end
|
28
29
|
|
29
|
-
def call(&action)
|
30
|
+
def call(*errors, millisecond_intervals: nil, &action)
|
31
|
+
errors = errors.flatten
|
32
|
+
millisecond_intervals ||= [0]
|
33
|
+
|
34
|
+
intervals = millisecond_intervals.to_enum
|
35
|
+
|
30
36
|
retries = 0
|
31
37
|
|
32
38
|
error = nil
|
33
39
|
probe = proc { |e| error = e }
|
34
40
|
|
35
41
|
loop do
|
36
|
-
success = Try.(
|
42
|
+
success = Try.(errors, error_probe: probe) do
|
37
43
|
action.call(retries)
|
38
44
|
end
|
39
45
|
|
@@ -43,7 +49,10 @@ class Retry
|
|
43
49
|
|
44
50
|
retries += 1
|
45
51
|
|
46
|
-
interval =
|
52
|
+
interval = intervals.next
|
53
|
+
|
54
|
+
telemetry.record :retried, Retry::Telemetry::Data.new(retries, error.class, interval)
|
55
|
+
|
47
56
|
break if interval.nil?
|
48
57
|
|
49
58
|
sleep (interval/1000.0)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Retry
|
2
|
+
module Telemetry
|
3
|
+
class Sink
|
4
|
+
include ::Telemetry::Sink
|
5
|
+
|
6
|
+
record :retried
|
7
|
+
end
|
8
|
+
|
9
|
+
Data = Struct.new :retry, :error, :millisecond_interval
|
10
|
+
|
11
|
+
def self.sink
|
12
|
+
Sink.new
|
13
|
+
end
|
14
|
+
|
15
|
+
module Register
|
16
|
+
def register_telemetry_sink(rtry)
|
17
|
+
sink = Retry::Telemetry.sink
|
18
|
+
rtry.telemetry.register(sink)
|
19
|
+
sink
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/retry.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evt-retry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Eventide Project
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: evt-try
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: evt-dependency
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: evt-telemetry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: test_bench
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,9 +88,13 @@ extra_rdoc_files: []
|
|
60
88
|
files:
|
61
89
|
- lib/retry.rb
|
62
90
|
- lib/retry/controls.rb
|
91
|
+
- lib/retry/controls/dependency.rb
|
63
92
|
- lib/retry/controls/error.rb
|
93
|
+
- lib/retry/controls/receiver.rb
|
64
94
|
- lib/retry/controls/time.rb
|
65
95
|
- lib/retry/retry.rb
|
96
|
+
- lib/retry/substitute.rb
|
97
|
+
- lib/retry/telemetry.rb
|
66
98
|
homepage: https://github.com/eventide-project/retry
|
67
99
|
licenses:
|
68
100
|
- MIT
|
@@ -83,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
115
|
version: '0'
|
84
116
|
requirements: []
|
85
117
|
rubyforge_project:
|
86
|
-
rubygems_version: 2.
|
118
|
+
rubygems_version: 2.7.3
|
87
119
|
signing_key:
|
88
120
|
specification_version: 4
|
89
121
|
summary: Retry an execution that terminates with an error
|