File tree Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change 5
5
### Changed
6
6
7
7
* retry_block now takes keyword arguments instead of positional (backwards incompatible)
8
+ * retry_block ` retry_count ` arg now counts up from 0, instead of old ` retries_remaining `
8
9
9
10
### Added
10
11
Original file line number Diff line number Diff line change @@ -108,8 +108,7 @@ def retry_statuses
108
108
# every retry. The block will be yielded keyword arguments:
109
109
# * env [Faraday::Env]: Request environment
110
110
# * options [Faraday::Options]: middleware options
111
- # * retries_remaining [Integer]: how many more possible retries are
112
- # remaining
111
+ # * retry_count [Integer]: how many retries have already occured (starts at 0)
113
112
# * exception [Exception]: exception that triggered the retry,
114
113
# will be the synthetic `Faraday::RetriableResponse` if the
115
114
# retry was triggered by something other than an exception.
@@ -157,7 +156,7 @@ def call(env)
157
156
@options . retry_block . call (
158
157
env : env ,
159
158
options : @options ,
160
- retries_remaining : retries ,
159
+ retry_count : @options . max - ( retries + 1 ) ,
161
160
exception : e ,
162
161
will_retry_in : sleep_amount
163
162
)
Original file line number Diff line number Diff line change 99
99
expect ( retry_block_calls . first [ :exception ] ) . to be_kind_of ( Errno ::ETIMEDOUT )
100
100
expect ( retry_block_calls . first [ :options ] ) . to be_kind_of ( Faraday ::Options )
101
101
expect ( retry_block_calls . first [ :env ] ) . to be_kind_of ( Faraday ::Env )
102
- expect ( retry_block_calls . first [ :will_retry_in ] ) . to be_kind_of ( Float )
103
- expect ( retry_block_calls . first [ :retries_remaining ] ) . to eq 1
102
+ expect ( retry_block_calls . first [ :retry_count ] ) . to be_kind_of ( Integer )
103
+ expect ( retry_block_calls . first [ :retry_count ] ) . to eq 0
104
+ end
105
+
106
+ it "increments retry_count" do
107
+ expect ( retry_block_calls [ 1 ] [ :retry_count ] ) . to eq 1
104
108
end
105
109
end
106
110
end
You can’t perform that action at this time.
0 commit comments