line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Job::Manager::Job; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Job::Manager::Job::VERSION = '0.16'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
BEGIN { |
6
|
1
|
|
|
1
|
|
5943
|
$Job::Manager::Job::AUTHORITY = 'cpan:TEX'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
# ABSTRACT: baseclass for any Job manaed by Job::Manager |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
34
|
use 5.010_000; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
11
|
1
|
|
|
1
|
|
5
|
use mro 'c3'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
12
|
1
|
|
|
1
|
|
33
|
use feature ':5.10'; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
99
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
604
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use namespace::autoclean; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# use IO::Handle; |
18
|
|
|
|
|
|
|
# use autodie; |
19
|
|
|
|
|
|
|
# use MooseX::Params::Validate; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'config' => ( |
22
|
|
|
|
|
|
|
'is' => 'ro', |
23
|
|
|
|
|
|
|
'isa' => 'Config::Yak', |
24
|
|
|
|
|
|
|
'required' => 0, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has 'logger' => ( |
28
|
|
|
|
|
|
|
'is' => 'rw', |
29
|
|
|
|
|
|
|
'isa' => 'Log::Tree', |
30
|
|
|
|
|
|
|
'required' => 1, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has 'worker' => ( |
34
|
|
|
|
|
|
|
'is' => 'rw', |
35
|
|
|
|
|
|
|
'isa' => 'Job::Manager::Worker', |
36
|
|
|
|
|
|
|
'lazy' => 1, |
37
|
|
|
|
|
|
|
'builder' => '_init_worker', |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub forked { |
41
|
|
|
|
|
|
|
my $self = shift; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$self->logger()->forked(); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
return 1; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _startup { |
49
|
|
|
|
|
|
|
my $self = shift; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Nothing to do |
52
|
|
|
|
|
|
|
return 1; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub run { |
56
|
|
|
|
|
|
|
my $self = shift; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
$self->_startup(); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
return $self->worker()->run(); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _init_worker { |
64
|
|
|
|
|
|
|
die('Abstract base class. Go, get your own derviate class!'); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
no Moose; |
68
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=pod |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=encoding utf-8 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 NAME |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Job::Manager::Job - baseclass for any Job manaed by Job::Manager |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 DESCRIPTION |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This class implements an abstract Job that can be fed to Job::Manager::JobQueue. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 METHODS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 run |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This sub is called when this Job begins execution. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 _init_worker |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Subclasses need to override this sub. It should return a subclass of Job::Manager::Worker. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 forked |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Invoked just before run but after the fork(). |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 NAME |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Job::Manager::Job - Abstract Job class |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 AUTHOR |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Dominik Schulz <dominik.schulz@gauner.org> |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Dominik Schulz. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
111
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
__END__ |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1; # End of Job::Manager::Job |