| 1 | package Jonk::Job; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 0 | my ($class, $jonk, $job) =@_; | |||||||||||||||||||||||||||||||||||||||||
| 8 | 0 | bless { | |||||||||||||||||||||||||||||||||||||||||
| 9 | job => $job, | ||||||||||||||||||||||||||||||||||||||||||
| 10 | _jonk => $jonk, | ||||||||||||||||||||||||||||||||||||||||||
| 11 | _completed => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 12 | _failed => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 13 | _aborted => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 14 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub completed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
completed: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | Carp::croak 'job is already failed.' if $self->is_failed; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | Carp::croak 'job is already aborted.' if $self->is_aborted; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | $self->{_completed} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | $self->{_jonk}->_delete($self->id); | |||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub failed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
failed: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my ($self, $opt) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | Carp::croak 'job is already complated.' if $self->is_completed; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | Carp::croak 'job is already aborted.' if $self->is_aborted; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | $self->{_failed} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 34 | $self->{_jonk}->_failed( | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $self->id => $opt | |||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub aborted { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
aborted: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | Carp::croak 'job is already complated.' if $self->is_completed; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | Carp::croak 'job is already failed.' if $self->is_failed; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | $self->{_aborted} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $self->{_jonk}->_delete($self->id); | |||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub id { $_[0]->{job}->{id} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | sub func { $_[0]->{job}->{func} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
func: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub raw_arg { $_[0]->{job}->{arg} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
raw_arg: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub arg { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
arg: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | $self->{_jonk}->{functions}->{$self->func}->{deserializer}->($self->{job}->{arg}); | |||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub enqueue_time { $_[0]->{job}->{enqueue_time} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enqueue_time: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | sub grabbed_until { $_[0]->{job}->{grabbed_until} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
grabbed_until: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | sub retry_cnt { $_[0]->{job}->{retry_cnt} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
retry_cnt: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub run_after { $_[0]->{job}->{run_after} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_after: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub priority { $_[0]->{job}->{priority} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
priority: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub is_completed { $_[0]->{_completed} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_completed: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | sub is_failed { $_[0]->{_failed} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_failed: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | sub is_aborted { $_[0]->{_aborted} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_aborted: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | unless ($self->is_completed or $self->is_aborted or $self->is_failed) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->is_completed or $self->is_aborted or $self->is_failed
$self->is_completed or $self->is_aborted
MC/DC0%0/3
$self->is_completed or $self->is_aborted or $self->is_failed
$self->is_completed
$self->is_aborted
$self->is_failed
Truth table0%0/4
A or B or C
A= $self->is_completedB= $self->is_abortedC= $self->is_failed
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | Carp::cluck "job is not (complete|fail|abor)ed. this job auto failed."; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $self->failed; | |||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | __END__ | ||||||||||||||||||||||||||||||||||||||||||