Retry/Interval/Fibonacci.pm

filter: Statementstmt 100% 21 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 100% 29 / 29 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Retry/Interval/Constant.pm ↑ Summary
1 package AnyEvent::Retry::Interval::Fibonacci;
2 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 $AnyEvent::Retry::Interval::Fibonacci::VERSION = '0.03';
4 }
5 # ABSTRACT: fibonacci back-off
6 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use MooseX::Types::Common::Numeric qw(PositiveNum);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use Math::Fibonacci qw(term);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶use true;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 with 'AnyEvent::Retry::Interval';
15  
16 2 has 'scale' => (
17 is => 'ro',
18 isa => PositiveNum,
19 default => 1.0,
20 );
21  
22 5 ▶sub reset {}
Subroutine reset: called CC=1 SCAR=0.0
23  
24 44 ▶sub next {
Subroutine next: called CC=1 SCAR=0.0
25 44 my ($self, $i) = @_;
26 44 return $self->scale * term($i);
27 }
28  
29 2 __PACKAGE__->meta->make_immutable;
30  
31  
32  
33 =pod
34  
35 =head1 NAME
36  
37 AnyEvent::Retry::Interval::Fibonacci - fibonacci back-off
38  
39 =head1 VERSION
40  
41 version 0.03
42  
43 =head1 SYNOPSIS
44  
45 C<AnyEvent::Retry::Interval> that waits longer and longer after each
46 failed attempt.
47  
48 =head1 INITARGS
49  
50 =head2 scale
51  
52 A number greater than 0 that the fibonacci number is multiplied by
53 before being returned. For example, to wait 1 millisecond, then 1
54 millisecond, then 2 milliseconds, then 3 ..., pass C<scale => 1/1000>.
55  
56 =head1 NOTES
57  
58 The fibonacci number is computed with L<Math::Fibonacci>. This may yield
59 slightly different results from the iterative C<F(n) = F(n-2) + F(n-1)>
60 method.
61  
62 =head1 AUTHOR
63  
64 Jonathan Rockway <jrockway@cpan.org>
65  
66 =head1 COPYRIGHT AND LICENSE
67  
68 This software is copyright (c) 2010 by Jonathan Rockway.
69  
70 This is free software; you can redistribute it and/or modify it under
71 the same terms as the Perl 5 programming language system itself.
72  
73 =cut
74  
75  
76 __END__
« Retry/Interval/Constant.pm ↑ Summary