Algorithm-Retry

 view release on metacpan or  search on metacpan

lib/Algorithm/Retry/ExponentialBackoff.pm  view on Meta::CPAN

package Algorithm::Retry::ExponentialBackoff;

our $DATE = '2019-04-10'; # DATE
our $VERSION = '0.002'; # VERSION

use strict;
use warnings;

use parent qw(Algorithm::Retry);

our %SPEC;

$SPEC{new} = {
    v => 1.1,
    is_class_meth => 1,
    is_func => 0,
    args => {
        %Algorithm::Retry::attr_consider_actual_delay,
        %Algorithm::Retry::attr_max_attempts,
        %Algorithm::Retry::attr_jitter_factor,
        %Algorithm::Retry::attr_delay_on_success,
        %Algorithm::Retry::attr_max_delay,
        initial_delay => {
            summary => 'Initial delay for the first attempt after failure, '.
                'in seconds',
            schema => 'ufloat*',
            req => 1,
        },
        exponent_base => {
            schema => 'ufloat*',
            default => 2,
        },
    },
    result_naked => 1,
    result => {
        schema => 'obj*',
    },
};

sub _success {
    my ($self, $timestamp) = @_;
    $self->{delay_on_success};
}

sub _failure {
    my ($self, $timestamp) = @_;
    my $delay = $self->{initial_delay} *
        $self->{exponent_base} ** ($self->{_attempts}-1);
}

1;
# ABSTRACT: Backoff exponentially

__END__

=pod

=encoding UTF-8

=head1 NAME

Algorithm::Retry::ExponentialBackoff - Backoff exponentially

=head1 VERSION

This document describes version 0.002 of Algorithm::Retry::ExponentialBackoff (from Perl distribution Algorithm-Retry), released on 2019-04-10.

=head1 SYNOPSIS



( run in 1.292 second using v1.01-cache-2.11-cpan-5b529ec07f3 )