Algorithm-Retry
view release on metacpan or search on metacpan
Source code for a work means the preferred form of the work for making
modifications to it. For an executable file, complete source code means
all the source code for all modules it contains; but, as a special
exception, it need not include source code for modules which are standard
libraries that accompany the operating system on which the executable
file runs, or for standard header files or definitions files that
accompany that operating system.
4. You may not copy, modify, sublicense, distribute or transfer the
Program except as expressly provided under this General Public License.
Any attempt otherwise to copy, modify, sublicense, distribute or transfer
the Program is void, and will automatically terminate your rights to use
the Program under this License. However, parties who have received
copies, or rights to use copies, from you under this General Public
License will not have their licenses terminated so long as such parties
remain in full compliance.
5. By copying, distributing or modifying the Program (or any work based
on the Program) you indicate your acceptance of this license to do so,
and all its terms and conditions.
If you set this to a value larger than 0, the actual delay will be
between a random number between original_delay * (1-jitter_factor)
and original_delay * (1+jitter_factor). Jitters are usually added to
avoid so-called "thundering herd" problem.
* max_attempts => *uint* (default: 0)
Maximum number consecutive failures before giving up.
0 means to retry endlessly without ever giving up. 1 means to give
up after a single failure (i.e. no retry attempts). 2 means to retry
once after a failure. Note that after a success, the number of
attempts is reset (as expected). So if max_attempts is 3, and if you
fail twice then succeed, then on the next failure the algorithm will
retry again for a maximum of 3 times.
Return value: (obj)
success
Usage:
lib/Algorithm/Retry.pm view on Meta::CPAN
},
);
our %attr_max_attempts = (
max_attempts => {
summary => 'Maximum number consecutive failures before giving up',
schema => 'uint*',
default => 0,
description => <<'_',
0 means to retry endlessly without ever giving up. 1 means to give up after a
single failure (i.e. no retry attempts). 2 means to retry once after a failure.
Note that after a success, the number of attempts is reset (as expected). So if
max_attempts is 3, and if you fail twice then succeed, then on the next failure
the algorithm will retry again for a maximum of 3 times.
_
},
);
our %attr_jitter_factor = (
lib/Algorithm/Retry.pm view on Meta::CPAN
If you set this to a value larger than 0, the actual delay will be between a
random number between original_delay * (1-jitter_factor) and original_delay *
(1+jitter_factor). Jitters are usually added to avoid so-called "thundering
herd" problem.
=item * B<max_attempts> => I<uint> (default: 0)
Maximum number consecutive failures before giving up.
0 means to retry endlessly without ever giving up. 1 means to give up after a
single failure (i.e. no retry attempts). 2 means to retry once after a failure.
Note that after a success, the number of attempts is reset (as expected). So if
max_attempts is 3, and if you fail twice then succeed, then on the next failure
the algorithm will retry again for a maximum of 3 times.
=back
Return value: (obj)
lib/Algorithm/Retry/Constant.pm view on Meta::CPAN
This document describes version 0.002 of Algorithm::Retry::Constant (from Perl distribution Algorithm-Retry), released on 2019-04-10.
=head1 SYNOPSIS
use Algorithm::Retry::Constant;
# 1. instantiate
my $ar = Algorithm::Retry::Constant->new(
#consider_actual_delay => 1, # optional, default 0
#max_attempts => 0, # optional, default 0 (retry endlessly)
#jitter_factor => 0, # optional, set to positive value to add randomness
delay => 2, # required
#delay_on_success => 0, # optional, default 0
);
# 2. log success/failure and get a new number of seconds to delay, timestamp is
# optional argument (default is current time) but must be monotonically
# increasing.
my $secs = $ar->failure(1554652553); # => 2
lib/Algorithm/Retry/Constant.pm view on Meta::CPAN
If you set this to a value larger than 0, the actual delay will be between a
random number between original_delay * (1-jitter_factor) and original_delay *
(1+jitter_factor). Jitters are usually added to avoid so-called "thundering
herd" problem.
=item * B<max_attempts> => I<uint> (default: 0)
Maximum number consecutive failures before giving up.
0 means to retry endlessly without ever giving up. 1 means to give up after a
single failure (i.e. no retry attempts). 2 means to retry once after a failure.
Note that after a success, the number of attempts is reset (as expected). So if
max_attempts is 3, and if you fail twice then succeed, then on the next failure
the algorithm will retry again for a maximum of 3 times.
=back
Return value: (obj)
=head1 HOMEPAGE
lib/Algorithm/Retry/ExponentialBackoff.pm view on Meta::CPAN
This document describes version 0.002 of Algorithm::Retry::ExponentialBackoff (from Perl distribution Algorithm-Retry), released on 2019-04-10.
=head1 SYNOPSIS
use Algorithm::Retry::ExponentialBackoff;
# 1. instantiate
my $ar = Algorithm::Retry::ExponentialBackoff->new(
#consider_actual_delay => 1, # optional, default 0
#max_attempts => 0, # optional, default 0 (retry endlessly)
#jitter_factor => 0.25, # optional, default 0
initial_delay => 5, # required
#max_delay => 100, # optional
#exponent_base => 2, # optional, default 2 (binary exponentiation)
#delay_on_success => 0, # optional, default 0
);
# 2. log success/failure and get a new number of seconds to delay, timestamp is
# optional but must be monotonically increasing.
lib/Algorithm/Retry/ExponentialBackoff.pm view on Meta::CPAN
If you set this to a value larger than 0, the actual delay will be between a
random number between original_delay * (1-jitter_factor) and original_delay *
(1+jitter_factor). Jitters are usually added to avoid so-called "thundering
herd" problem.
=item * B<max_attempts> => I<uint> (default: 0)
Maximum number consecutive failures before giving up.
0 means to retry endlessly without ever giving up. 1 means to give up after a
single failure (i.e. no retry attempts). 2 means to retry once after a failure.
Note that after a success, the number of attempts is reset (as expected). So if
max_attempts is 3, and if you fail twice then succeed, then on the next failure
the algorithm will retry again for a maximum of 3 times.
=item * B<max_delay> => I<ufloat>
Maximum delay time, in seconds.
=back
lib/Algorithm/Retry/Fibonacci.pm view on Meta::CPAN
This document describes version 0.002 of Algorithm::Retry::Fibonacci (from Perl distribution Algorithm-Retry), released on 2019-04-10.
=head1 SYNOPSIS
use Algorithm::Retry::Fibonacci;
# 1. instantiate
my $ar = Algorithm::Retry::Fibonacci->new(
#max_attempts => 0, # optional, default 0 (retry endlessly)
#jitter_factor => 0.25, # optional, default 0
initial_delay1 => 2, # required
initial_delay2 => 3, # required
#max_delay => 20, # optional
#delay_on_success => 0, # optional, default 0
);
# 2. log success/failure and get a new number of seconds to delay, timestamp is
# optional but must be monotonically increasing.
lib/Algorithm/Retry/Fibonacci.pm view on Meta::CPAN
If you set this to a value larger than 0, the actual delay will be between a
random number between original_delay * (1-jitter_factor) and original_delay *
(1+jitter_factor). Jitters are usually added to avoid so-called "thundering
herd" problem.
=item * B<max_attempts> => I<uint> (default: 0)
Maximum number consecutive failures before giving up.
0 means to retry endlessly without ever giving up. 1 means to give up after a
single failure (i.e. no retry attempts). 2 means to retry once after a failure.
Note that after a success, the number of attempts is reset (as expected). So if
max_attempts is 3, and if you fail twice then succeed, then on the next failure
the algorithm will retry again for a maximum of 3 times.
=item * B<max_delay> => I<ufloat>
Maximum delay time, in seconds.
=back
( run in 1.275 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )