line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
1535
|
use 5.008; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
52
|
|
2
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
53
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
58
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Data::Conveyor::Stage::SingleTicket; |
6
|
|
|
|
|
|
|
BEGIN { |
7
|
1
|
|
|
1
|
|
24
|
$Data::Conveyor::Stage::SingleTicket::VERSION = '1.103130'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
# ABSTRACT: Stage-based conveyor-belt-like ticket handling system |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Base class for stages handling a single ticket (i.e., policy or delegation, |
12
|
|
|
|
|
|
|
# but not queue). |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# To use it, create an object of this class, set the ticket and |
15
|
|
|
|
|
|
|
# call run(). You can then read the status the stage's ticket and act on it. |
16
|
1
|
|
|
1
|
|
6
|
use Error::Hierarchy::Util 'assert_defined'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
62
|
|
17
|
1
|
|
|
1
|
|
6
|
use parent 'Data::Conveyor::Stage'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
18
|
|
|
|
|
|
|
__PACKAGE__->mk_framework_object_accessors( |
19
|
|
|
|
|
|
|
ticket => 'ticket', |
20
|
|
|
|
|
|
|
stage_delegate => 'stage_delegate', |
21
|
|
|
|
|
|
|
)->mk_scalar_accessors(qw(expected_stage log_max_level_previous)); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub MUNGE_CONSTRUCTOR_ARGS { |
24
|
1
|
|
|
1
|
1
|
81
|
my ($self, @args) = @_; |
25
|
1
|
|
|
|
|
15
|
@args = $self->SUPER::MUNGE_CONSTRUCTOR_ARGS(@args); |
26
|
1
|
|
|
|
|
379
|
push @args => |
27
|
|
|
|
|
|
|
(stage_delegate => $self->delegate->make_delegate('stage_delegate')); |
28
|
1
|
|
|
|
|
2329
|
@args; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub main { |
32
|
0
|
|
|
0
|
1
|
|
my ($self, %args) = @_; |
33
|
0
|
|
|
|
|
|
$self->SUPER::main(%args); |
34
|
0
|
|
|
|
|
|
assert_defined $self->expected_stage, 'called without set expected_stage.'; |
35
|
0
|
|
|
|
|
|
assert_defined $self->ticket, 'called without set ticket.'; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Remember the log's previous max_level settings and temporarily (until |
38
|
|
|
|
|
|
|
# the end of the ticket stage) set the log's max_level to the one |
39
|
|
|
|
|
|
|
# indicated by the ticket. This mechanism can be used to increase a faulty |
40
|
|
|
|
|
|
|
# ticket's log level from the regsh so that verbose information can be |
41
|
|
|
|
|
|
|
# seen in the log. But only override with the ticket's log level if it is |
42
|
|
|
|
|
|
|
# higher than the current log level; we don't want a ticket to actually |
43
|
|
|
|
|
|
|
# reduce the current log level. |
44
|
0
|
|
|
|
|
|
$self->log_max_level_previous($self->log->max_level); |
45
|
0
|
0
|
|
|
|
|
if ($self->ticket->get_log_level > $self->log->max_level) { |
46
|
0
|
|
|
|
|
|
$self->log->max_level($self->ticket->get_log_level); |
47
|
|
|
|
|
|
|
} |
48
|
0
|
0
|
|
|
|
|
unless ($self->ticket->stage->name eq $self->expected_stage) { |
49
|
0
|
|
|
|
|
|
throw Data::Conveyor::Exception::Ticket::InvalidStage( |
50
|
|
|
|
|
|
|
stage => $self->ticket->stage,); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub end { |
55
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# After handling all exceptions, if the ticket status is anything else |
58
|
|
|
|
|
|
|
# than TS_RUNNING, but the rc is RC_ERROR, set the status to TS_RUNNING so |
59
|
|
|
|
|
|
|
# that the ticket gets passed on to the notify stage. |
60
|
|
|
|
|
|
|
# |
61
|
|
|
|
|
|
|
# The reason is that we don't want erroneous tickets to be left on hold. |
62
|
|
|
|
|
|
|
# If there's a reason it would normally go on hold and another reason it's |
63
|
|
|
|
|
|
|
# erroneous, the error takes precedence. |
64
|
0
|
0
|
|
|
|
|
$self->ticket->status($self->delegate->TS_RUNNING) |
65
|
|
|
|
|
|
|
if $self->ticket->rc eq $self->delegate->RC_ERROR; |
66
|
0
|
|
|
|
|
|
$self->stage_delegate->handle_stage_end($self); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# restore the log's previous max_level setting. |
69
|
0
|
|
|
|
|
|
$self->log->max_level($self->log_max_level_previous); |
70
|
0
|
|
|
|
|
|
$self->ticket->store; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |