| 1 | package Qless::RecurringJob; | ||||||||||
| 2 | =head1 NAME | ||||||||||
| 3 | |||||||||||
| 4 | Qless::RecurringJob | ||||||||||
| 5 | |||||||||||
| 6 | =cut | ||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use strict; use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use base 'Qless::BaseJob'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use JSON::XS qw(decode_json encode_json); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 13 | 0 | my $class = shift; | |||||||||
| 14 | |||||||||||
| 15 | 0 | my ($client, $args) = @_; | |||||||||
| 16 | |||||||||||
| 17 | 0 | ▶ | $class = ref $class if ref $class; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 0 | my $self = $class->SUPER::new($client, $args); | |||||||||
| 19 | |||||||||||
| 20 | 0 | foreach my $key (qw(retries interval count)) { | |||||||||
| 21 | 0 | $self->{$key} = $args->{ $key }; | |||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | 0 | $self; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 0 | ▶ | sub _set_key { | ||||||||
|
Subroutine
_set_key: not called CC=1 SCAR=6.9
| |||||||||||
| 28 | 0 | my ($self, $key, $value) = @_; | |||||||||
| 29 | 0 | $self->client->_recur([], 'update', $self->{'jid'}, $key, $value); | |||||||||
| 30 | 0 | $self->{$key} = $value; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 0 | ▶ | sub priority { $#_ == 0 ? $_[0]->SUPER::priority : $_[0]->_set_key('priority', $_[1]) } | ||||||||
|
Subroutine
priority: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||
| 34 | 0 | ▶ | sub retries { $#_ == 0 ? $_[0]->{'retries'} : $_[0]->_set_key('retries', $_[1]) } | ||||||||
|
Subroutine
retries: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||
| 35 | 0 | ▶ | sub interval { $#_ == 0 ? $_[0]->{'interval'} : $_[0]->_set_key('interval', $_[1]) } | ||||||||
|
Subroutine
interval: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||
| 36 | 0 | ▶ | sub data { $#_ == 0 ? $_[0]->SUPER::data : $_[0]->_set_key('data', encode_json($_[1])) } | ||||||||
|
Subroutine
data: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||
| 37 | 0 | ▶ | sub klass { $#_ == 0 ? $_[0]->SUPER::klass : $_[0]->_set_key('klass', $_[1]) } | ||||||||
|
Subroutine
klass: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||
| 38 | 0 | ▶ | sub count { $_[0]->{'count'} } | ||||||||
|
Subroutine
count: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 39 | |||||||||||
| 40 | 0 | ▶ | sub next { | ||||||||
|
Subroutine
next: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 41 | 0 | my ($self) = @_; | |||||||||
| 42 | 0 | return $self->client->redis->zscore('ql:q:'.$self->queue_name.'-recur', $self->jid); | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 0 | ▶ | sub move { | ||||||||
|
Subroutine
move: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 46 | 0 | my ($self, $queue) = @_; | |||||||||
| 47 | 0 | $self->client->_recur([], 'update', $self->jid, 'queue', $queue); | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 0 | ▶ | sub cancel { | ||||||||
|
Subroutine
cancel: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 51 | 0 | my ($self, $queue) = @_; | |||||||||
| 52 | 0 | $self->client->_recur([], 'off', $self->jid); | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 0 | ▶ | sub tag { | ||||||||
|
Subroutine
tag: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 56 | 0 | my ($self, @tags) = @_; | |||||||||
| 57 | 0 | $self->client->_recur([], 'tag', $self->jid, @tags); | |||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | 0 | ▶ | sub untag { | ||||||||
|
Subroutine
untag: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 61 | 0 | my ($self, @tags) = @_; | |||||||||
| 62 | 0 | $self->client->_recur([], 'untag', $self->jid, @tags); | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 1 | 1; | |||||||||