line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Job::Machine::Base; |
2
|
|
|
|
|
|
|
$Job::Machine::Base::VERSION = '0.25'; |
3
|
1
|
|
|
1
|
|
9
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
5
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
104
|
|
6
|
1
|
|
|
1
|
|
397
|
use Job::Machine::DB; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
204
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
0
|
|
|
0
|
1
|
|
my ($class, %args) = @_; |
10
|
0
|
|
|
|
|
|
$args{db} = Job::Machine::DB->new( %args ); |
11
|
0
|
|
|
|
|
|
return bless \%args, $class; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
0
|
1
|
|
sub db { return $_[0]->{db} }; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub id { |
17
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
18
|
0
|
0
|
|
|
|
|
$self->{id} = $id if defined $id; |
19
|
0
|
|
|
|
|
|
return $self->{id}; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub subscribe { |
23
|
0
|
|
|
0
|
0
|
|
my ($self, $queue, $reply) = @_; |
24
|
0
|
|
0
|
|
|
|
$queue ||= $self->{queue}; |
25
|
0
|
|
0
|
|
|
|
$reply ||= 0; |
26
|
0
|
|
|
|
|
|
return $self->db->listen(queue => $queue, reply => $reply); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub job_log { |
30
|
0
|
|
|
0
|
1
|
|
my ($self, $msg) = @_; |
31
|
0
|
|
|
|
|
|
print STDERR $msg, "\n"; |
32
|
0
|
|
|
|
|
|
return; |
33
|
|
|
|
|
|
|
# $Carp::CarpLevel = 1; |
34
|
|
|
|
|
|
|
# carp($msg); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__END__ |