Algorithm-Backoff

 view release on metacpan or  search on metacpan

lib/Algorithm/Backoff/Exponential.pm  view on Meta::CPAN

package Algorithm::Backoff::Exponential;

use strict;
use warnings;

use parent qw(Algorithm::Backoff);

our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2024-02-24'; # DATE
our $DIST = 'Algorithm-Backoff'; # DIST
our $VERSION = '0.010'; # VERSION

our %SPEC;

$SPEC{new} = {
    v => 1.1,
    is_class_meth => 1,
    is_func => 0,
    args => {
        %Algorithm::Backoff::attr_consider_actual_delay,
        %Algorithm::Backoff::attr_max_actual_duration,
        %Algorithm::Backoff::attr_max_attempts,
        %Algorithm::Backoff::attr_jitter_factor,
        %Algorithm::Backoff::attr_delay_on_success,
        %Algorithm::Backoff::attr_min_delay,
        %Algorithm::Backoff::attr_max_delay,
        %Algorithm::Backoff::attr_initial_delay,
        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::Backoff::Exponential - Backoff exponentially

=head1 VERSION

This document describes version 0.010 of Algorithm::Backoff::Exponential (from Perl distribution Algorithm-Backoff), released on 2024-02-24.



( run in 1.247 second using v1.01-cache-2.11-cpan-63c85eba8c4 )