|
NAMEAlgorithm::Backoff::Constant - Backoff using a constant delay VERSIONThis document describes version 0.009 of Algorithm::Backoff::Constant (from Perl distribution Algorithm-Backoff), released on 2019-06-20. SYNOPSIS use Algorithm::Backoff::Constant;
# 1. instantiate
my $ab = Algorithm::Backoff::Constant->new(
#consider_actual_delay => 1, # optional, default 0
#max_actual_duration => 0, # optional, default 0 (retry endlessly)
#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 = $ab->failure(1554652553); # => 2
my $secs = $ab->success(); # => 0
my $secs = $ab->failure(); # => 2
Illustration using CLI show-backoff-delays (5 failures followed by 3 successes): % show-backoff-delays -a Constant --delay 2 \
0 0 0 0 0 1 1 1
2
2
2
2
2
0
0
0
DESCRIPTIONThis backoff strategy is one of the simplest: it waits X second(s) after each failure, or Y second(s) (default 0) after a success. There are limits on the number of attempts (`max_attempts`) and total duration (`max_actual_duration`). Some randomness can be introduced to avoid "thundering herd problem". METHODSnewUsage: new(%args) -> obj This function is not exported. Arguments ('*' denotes required arguments):
Return value: (obj) HOMEPAGEPlease visit the project's homepage at <https://metacpan.org/release/Algorithm-Backoff>. SOURCESource repository is at <https://github.com/perlancar/perl-Algorithm-Backoff>. BUGSPlease report any bugs or feature requests on the bugtracker website <https://rt.cpan.org/Public/Dist/Display.html?Name=Algorithm-Backoff> When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. SEE ALSOAlgorithm::Backoff Other "Algorithm::Backoff::*" classes. AUTHORperlancar <perlancar@cpan.org> COPYRIGHT AND LICENSEThis software is copyright (c) 2019 by perlancar@cpan.org. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
|