view release on metacpan or search on metacpan
lib/Action/Retry.pm view on Meta::CPAN
has non_blocking => (
is => 'ro',
default => sub { 0 },
);
# For non blocking mode, store the timestamp after which we can retry
has _needs_sleeping_until => (
is => 'rw',
default => sub { 0 },
init_arg => undef,
);
sub run {
my $self = shift;
while(1) {
if (my $timestamp = $self->_needs_sleeping_until) {
# we can't retry until we have waited enough time
lib/Action/Retry.pm view on Meta::CPAN
# Returns true if there were an exception evaluating to something true
sub { $_[0] }
It will be given these arguments:
=over
=item *
as first argument, a scalar which is the value of any exception that were
raised by the C<attempt_code>. Otherwise, undef.
=item *
as second argument, a HashRef, which contains these keys:
=over
=item action_retry
it's a reference on the ActionRetry instance. That way you can have access to
lib/Action/Retry/Strategy/Constant.pm view on Meta::CPAN
=head2 sleep_time
ro, Int, defaults to 1000 ( 1 second )
The number of milliseconds to wait between retries
=head2 max_retries_number
ro, Int|Undef, defaults to 10
The number of times we should retry before giving up. 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.
lib/Action/Retry/Strategy/Fibonacci.pm view on Meta::CPAN
is => 'ro',
lazy => 1,
default => sub { 0 },
);
# the current sequence term index
has _current_term_index => (
is => 'rw',
lazy => 1,
default => sub { $_[0]->initial_term_index },
init_arg => undef,
clearer => 1,
);
has multiplicator => (
is => 'ro',
lazy => 1,
default => sub { 1000 },
);
lib/Action/Retry/Strategy/Fibonacci.pm view on Meta::CPAN
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
lib/Action/Retry/Strategy/HelperRole/RetriesLimit.pm view on Meta::CPAN
is => 'ro',
lazy => 1,
default => sub { 10 },
);
# the current number of retries
has _current_retries_number => (
is => 'rw',
lazy => 1,
default => sub { 0 },
init_arg => undef,
clearer => 1,
);
around needs_to_retry => sub {
my $orig = shift;
my $self = shift;
defined $self->max_retries_number
or return $orig->($self, @_);
$orig->($self, @_) && $self->_current_retries_number < $self->max_retries_number
};
lib/Action/Retry/Strategy/HelperRole/SleepCapping.pm view on Meta::CPAN
# ABSTRACT: Helper to be consumed by Action::Retry Strategies, to enable capping the sleep time
use Moo::Role;
use List::Util qw(min);
has capped_sleep_time => (
is => 'ro',
lazy => 1,
default => sub { undef },
);
around compute_sleep_time => sub {
my $orig = shift;
my $self = shift;
return defined $self->capped_sleep_time
? min($orig->($self, @_), $self->capped_sleep_time)
: $orig->($self, @_);
lib/Action/Retry/Strategy/HelperRole/SleepTimeout.pm view on Meta::CPAN
$Action::Retry::Strategy::HelperRole::SleepTimeout::VERSION = '0.24';
}
# ABSTRACT: Helper to be consumed by Action::Retry Strategies, to enable giving up retrying when the sleep_time is too big
use Moo::Role;
has max_sleep_time => (
is => 'ro',
lazy => 1,
default => sub { undef },
);
around needs_to_retry => sub {
my $orig = shift;
my $self = shift;
defined $self->max_sleep_time
or return $orig->($self, @_);
$orig->($self, @_) && $self->compute_sleep_time < $self->max_sleep_time
};
lib/Action/Retry/Strategy/Linear.pm view on Meta::CPAN
is => 'ro',
lazy => 1,
default => sub { 1000 },
);
# the current sleep time, as it's computed
has _current_sleep_time => (
is => 'rw',
lazy => 1,
default => sub { $_[0]->initial_sleep_time },
init_arg => undef,
clearer => 1,
);
has multiplicator => (
is => 'ro',
lazy => 1,
default => sub { 2 },
);
lib/Action/Retry/Strategy/Linear.pm view on Meta::CPAN
ro, Int, defaults to 2
Number multiplied by the last sleep time. E.g. if set to 2, the time between
two retries will double. If set to 1, it'll remain constant. Defaults to 2
=head2 max_retries_number
ro, Int|Undef, 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