Action-Retry
view release on metacpan or search on metacpan
lib/Action/Retry.pm view on Meta::CPAN
# the same terms as the Perl 5 programming language system itself.
#
package Action::Retry;
{
$Action::Retry::VERSION = '0.24';
}
# ABSTRACT: Module to try to perform an action, with various ways of retrying and sleeping between retries.
use Module::Runtime qw(use_module);
use Scalar::Util qw(blessed);
use Time::HiRes qw(usleep gettimeofday);
use Carp;
use base 'Exporter';
our @EXPORT_OK = qw(retry);
# export by default if run from command line
our @EXPORT = ((caller())[1] eq '-e' ? @EXPORT_OK : ());
use Moo;
lib/Action/Retry.pm view on Meta::CPAN
isa => sub { ref $_[0] eq 'CODE' },
predicate => 1,
);
has strategy => (
is => 'ro',
default => sub { 'Constant' },
coerce => sub {
my $attr = $_[0];
blessed($attr)
and return $attr;
my $class_name = $attr;
my $constructor_params = {};
if (ref $attr eq 'HASH') {
$class_name = (keys %$attr)[0];
$constructor_params = $attr->{$class_name};
}
$class_name = $class_name =~ /^\+(.+)$/ ? $1 : "Action::Retry::Strategy::$class_name";
return use_module($class_name)->new($constructor_params);
},
( run in 0.444 second using v1.01-cache-2.11-cpan-de7293f3b23 )