| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Algorithm::Backoff::LIMD; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | our $DATE = '2019-06-20'; # DATE | 
| 4 |  |  |  |  |  |  | our $VERSION = '0.008'; # VERSION | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 1 |  |  | 1 |  | 53122 | use strict; | 
|  | 1 |  |  |  |  | 9 |  | 
|  | 1 |  |  |  |  | 25 |  | 
| 7 | 1 |  |  | 1 |  | 4 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 24 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 1 |  |  | 1 |  | 351 | use parent qw(Algorithm::Backoff); | 
|  | 1 |  |  |  |  | 245 |  | 
|  | 1 |  |  |  |  | 5 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | our %SPEC; | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | $SPEC{new} = { | 
| 14 |  |  |  |  |  |  | v => 1.1, | 
| 15 |  |  |  |  |  |  | is_class_meth => 1, | 
| 16 |  |  |  |  |  |  | is_func => 0, | 
| 17 |  |  |  |  |  |  | args => { | 
| 18 |  |  |  |  |  |  | %Algorithm::Backoff::attr_consider_actual_delay, | 
| 19 |  |  |  |  |  |  | %Algorithm::Backoff::attr_max_actual_duration, | 
| 20 |  |  |  |  |  |  | %Algorithm::Backoff::attr_max_attempts, | 
| 21 |  |  |  |  |  |  | %Algorithm::Backoff::attr_jitter_factor, | 
| 22 |  |  |  |  |  |  | %Algorithm::Backoff::attr_max_delay, | 
| 23 |  |  |  |  |  |  | %Algorithm::Backoff::attr_min_delay, | 
| 24 |  |  |  |  |  |  | %Algorithm::Backoff::attr_initial_delay, | 
| 25 |  |  |  |  |  |  | %Algorithm::Backoff::attr_delay_increment_on_failure, | 
| 26 |  |  |  |  |  |  | %Algorithm::Backoff::attr_delay_multiple_on_success, | 
| 27 |  |  |  |  |  |  | }, | 
| 28 |  |  |  |  |  |  | result_naked => 1, | 
| 29 |  |  |  |  |  |  | result => { | 
| 30 |  |  |  |  |  |  | schema => 'obj*', | 
| 31 |  |  |  |  |  |  | }, | 
| 32 |  |  |  |  |  |  | }; | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | sub _success { | 
| 35 | 3 |  |  | 3 |  | 6 | my ($self, $timestamp) = @_; | 
| 36 |  |  |  |  |  |  |  | 
| 37 | 3 | 50 |  |  |  | 7 | unless (defined $self->{_prev_delay}) { | 
| 38 | 0 |  |  |  |  | 0 | return $self->{_prev_delay} = $self->{initial_delay}; | 
| 39 |  |  |  |  |  |  | } | 
| 40 |  |  |  |  |  |  |  | 
| 41 | 3 |  |  |  |  | 6 | my $delay = $self->{_prev_delay} * $self->{delay_multiple_on_success}; | 
| 42 |  |  |  |  |  |  |  | 
| 43 | 3 |  |  |  |  | 5 | $delay; | 
| 44 |  |  |  |  |  |  | } | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | sub _failure { | 
| 47 | 5 |  |  | 5 |  | 6 | my ($self, $timestamp) = @_; | 
| 48 |  |  |  |  |  |  |  | 
| 49 | 5 | 100 |  |  |  | 11 | unless (defined $self->{_prev_delay}) { | 
| 50 | 1 |  |  |  |  | 4 | return $self->{_prev_delay} = $self->{initial_delay}; | 
| 51 |  |  |  |  |  |  | } | 
| 52 |  |  |  |  |  |  |  | 
| 53 | 4 |  |  |  |  | 5 | my $delay = $self->{_prev_delay} + $self->{delay_increment_on_failure}; | 
| 54 |  |  |  |  |  |  |  | 
| 55 | 4 |  |  |  |  | 8 | $delay; | 
| 56 |  |  |  |  |  |  | } | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | 1; | 
| 59 |  |  |  |  |  |  | # ABSTRACT: Linear Increment, Multiplicative Decrement (LIMD) backoff | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | __END__ |