| 1 | # | ||||||||||
| 2 | # This file is part of Action-Retry | ||||||||||
| 3 | # | ||||||||||
| 4 | # This software is copyright (c) 2013 by Damien "dams" Krotkine. | ||||||||||
| 5 | # | ||||||||||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||||||||||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||||||||||
| 8 | # | ||||||||||
| 9 | package Action::Retry::Strategy::HelperRole::SleepTimeout; | ||||||||||
| 10 | { | ||||||||||
| 11 | 7 | $Action::Retry::Strategy::HelperRole::SleepTimeout::VERSION = '0.24'; | |||||||||
| 12 | } | ||||||||||
| 13 | |||||||||||
| 14 | # ABSTRACT: Helper to be consumed by Action::Retry Strategies, to enable giving up retrying when the sleep_time is too big | ||||||||||
| 15 | |||||||||||
| 16 | 7 | ▶ | use Moo::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | has max_sleep_time => ( | ||||||||||
| 19 | is => 'ro', | ||||||||||
| 20 | lazy => 1, | ||||||||||
| 21 | 8 | ▶ | default => sub { undef }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 7 | ); | |||||||||
| 23 | |||||||||||
| 24 | 83 | ▶ | around needs_to_retry => sub { | ||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||
| 25 | 83 | my $orig = shift; | |||||||||
| 26 | 83 | my $self = shift; | |||||||||
| 27 | 83 | ▶ | defined $self->max_sleep_time | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | or return $orig->($self, @_); | ||||||||||
| 29 | 18 | ▶ | $orig->($self, @_) && $self->compute_sleep_time < $self->max_sleep_time | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | 7 | }; | |||||||||
| 31 | |||||||||||
| 32 | 7 | 1; | |||||||||
| 33 | |||||||||||
| 34 | __END__ | ||||||||||