line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Qless::RecurringJob; |
2
|
|
|
|
|
|
|
=head1 NAME |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
Qless::RecurringJob |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=cut |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
4
|
use strict; use warnings; |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
9
|
1
|
|
|
1
|
|
4
|
use base 'Qless::BaseJob'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
89
|
|
10
|
1
|
|
|
1
|
|
5
|
use JSON::XS qw(decode_json encode_json); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
521
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
my ($client, $args) = @_; |
16
|
|
|
|
|
|
|
|
17
|
0
|
0
|
|
|
|
|
$class = ref $class if ref $class; |
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
|
|
|
|
|
|
|
sub _set_key { |
28
|
0
|
|
|
0
|
|
|
my ($self, $key, $value) = @_; |
29
|
0
|
|
|
|
|
|
$self->client->_recur([], 'update', $self->{'jid'}, $key, $value); |
30
|
0
|
|
|
|
|
|
$self->{$key} = $value; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
0
|
0
|
|
sub priority { $#_ == 0 ? $_[0]->SUPER::priority : $_[0]->_set_key('priority', $_[1]) } |
34
|
0
|
0
|
|
0
|
0
|
|
sub retries { $#_ == 0 ? $_[0]->{'retries'} : $_[0]->_set_key('retries', $_[1]) } |
35
|
0
|
0
|
|
0
|
0
|
|
sub interval { $#_ == 0 ? $_[0]->{'interval'} : $_[0]->_set_key('interval', $_[1]) } |
36
|
0
|
0
|
|
0
|
0
|
|
sub data { $#_ == 0 ? $_[0]->SUPER::data : $_[0]->_set_key('data', encode_json($_[1])) } |
37
|
0
|
0
|
|
0
|
0
|
|
sub klass { $#_ == 0 ? $_[0]->SUPER::klass : $_[0]->_set_key('klass', $_[1]) } |
38
|
0
|
|
|
0
|
0
|
|
sub count { $_[0]->{'count'} } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub next { |
41
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
42
|
0
|
|
|
|
|
|
return $self->client->redis->zscore('ql:q:'.$self->queue_name.'-recur', $self->jid); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub move { |
46
|
0
|
|
|
0
|
0
|
|
my ($self, $queue) = @_; |
47
|
0
|
|
|
|
|
|
$self->client->_recur([], 'update', $self->jid, 'queue', $queue); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub cancel { |
51
|
0
|
|
|
0
|
0
|
|
my ($self, $queue) = @_; |
52
|
0
|
|
|
|
|
|
$self->client->_recur([], 'off', $self->jid); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub tag { |
56
|
0
|
|
|
0
|
0
|
|
my ($self, @tags) = @_; |
57
|
0
|
|
|
|
|
|
$self->client->_recur([], 'tag', $self->jid, @tags); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub untag { |
61
|
0
|
|
|
0
|
0
|
|
my ($self, @tags) = @_; |
62
|
0
|
|
|
|
|
|
$self->client->_recur([], 'untag', $self->jid, @tags); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |