kamui/retriable

[Question] Custom Interval

404pilot opened this issue · 1 comments

Hey all,

I am new to ruby and trying to use this gem.

Running following code:

Retriable.retriable intervals: [1, 2, 3, 4] do
  puts "time: #{Time.now}"
  raise 'An error has occured.'
end

the result is:

time: 2015-09-30 04:04:11 +0000

time: 2015-09-30 04:04:12 +0000

time: 2015-09-30 04:04:14 +0000

time: 2015-09-30 04:04:17 +0000

but should it re-try one more time? and the last interval is 4 seconds? I thought the number of execution is original one time plus the size of the interval array?

Thanks.

kamui commented

Yep, that's a bug. It has to do witheach_with_index starting the try count at 1 and the equality check expecting it to start at 0. I'll fix this in the next release. Thanks for the report.