Action-Retry

 view release on metacpan or  search on metacpan

lib/Action/Retry/Strategy/Fibonacci.pm  view on Meta::CPAN

    return;
}

sub compute_sleep_time {
    my ($self) = @_;
#    print STDERR " -- sleep time is " . term($self->_current_term_index) * $self->multiplicator . "\n";
    return term($self->_current_term_index) * $self->multiplicator;
}

sub next_step {
    my ($self) = @_;
    $self->_current_term_index($self->_current_term_index + 1);
    return;
}

sub needs_to_retry { 1 }

# Inherited from Action::Retry::Strategy::HelperRole::RetriesLimit


# Inherited from Action::Retry::Strategy::HelperRole::SleepTimeout


1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Action::Retry::Strategy::Fibonacci - Fibonacci incrementation of sleep time strategy

=head1 VERSION

version 0.24

=head1 SYNOPSIS

To be used as strategy in L<Action::Retry>

=head1 DESCRIPTION

Sleeps incrementally by following the Fibonacci sequence : F(i) = F(i-1) +
F(i-2) starting from 0,1. By default F(0) = 0, F(1) = 1, F(2) = 1, F(3) = 2

=head1 ATTRIBUTES

=head2 initial_term_index

  ro, Int, defaults to 0

Term number of the Fibonacci sequence to start at. Defaults to 0

=head2 multiplicator

  ro, Int, defaults to 1000

Number of milliseconds that will be multiplied by the fibonacci sequence term
value. Defaults to 1000 ( 1 second )

=head2 max_retries_number

  ro, Int, defaults to 10

The number of times we should retry before giving up. If set to undef, never stop retrying

=head2 max_sleep_time

  ro, Int|Undef, defaults to undef

If Action::Retry is about to sleep more than this number ( in milliseconds ),
stop retrying. If set to undef, never stop retrying

=head1 AUTHOR

Damien "dams" Krotkine

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Damien "dams" Krotkine.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut



( run in 0.717 second using v1.01-cache-2.11-cpan-39bf76dae61 )