| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package DR::TarantoolQueue::Task; |
|
2
|
5
|
|
|
5
|
|
63
|
use utf8; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
43
|
|
|
3
|
5
|
|
|
5
|
|
159
|
use strict; |
|
|
5
|
|
|
|
|
8
|
|
|
|
5
|
|
|
|
|
101
|
|
|
4
|
5
|
|
|
5
|
|
26
|
use warnings; |
|
|
5
|
|
|
|
|
8
|
|
|
|
5
|
|
|
|
|
147
|
|
|
5
|
5
|
|
|
5
|
|
29
|
use Mouse; |
|
|
5
|
|
|
|
|
11
|
|
|
|
5
|
|
|
|
|
37
|
|
|
6
|
5
|
|
|
5
|
|
2317
|
use JSON::XS (); |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
97
|
|
|
7
|
5
|
|
|
5
|
|
26
|
use Carp; |
|
|
5
|
|
|
|
|
13
|
|
|
|
5
|
|
|
|
|
1614
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has space => (is => 'ro', isa => 'Str', required => 1); |
|
10
|
|
|
|
|
|
|
has status => ( |
|
11
|
|
|
|
|
|
|
is => 'ro', |
|
12
|
|
|
|
|
|
|
isa => 'Str', |
|
13
|
|
|
|
|
|
|
required => 1, |
|
14
|
|
|
|
|
|
|
writer => '_set_status' |
|
15
|
|
|
|
|
|
|
); |
|
16
|
|
|
|
|
|
|
has tube => (is => 'ro', isa => 'Str', required => 1); |
|
17
|
|
|
|
|
|
|
has id => (is => 'ro', isa => 'Str', required => 1); |
|
18
|
|
|
|
|
|
|
has rawdata => ( |
|
19
|
|
|
|
|
|
|
is => 'ro', |
|
20
|
|
|
|
|
|
|
isa => 'Str|Undef', |
|
21
|
|
|
|
|
|
|
required => 1, |
|
22
|
|
|
|
|
|
|
writer => '_set_rawdata', |
|
23
|
|
|
|
|
|
|
trigger => sub { $_[0]->_clean_data } |
|
24
|
|
|
|
|
|
|
); |
|
25
|
|
|
|
|
|
|
has data => ( |
|
26
|
|
|
|
|
|
|
is => 'ro', |
|
27
|
|
|
|
|
|
|
isa => 'HashRef|ArrayRef|Str|Undef', |
|
28
|
|
|
|
|
|
|
lazy => 1, |
|
29
|
|
|
|
|
|
|
clearer => '_clean_data', |
|
30
|
|
|
|
|
|
|
builder => sub { |
|
31
|
|
|
|
|
|
|
my ($self) = @_; |
|
32
|
|
|
|
|
|
|
return undef unless defined $self->rawdata; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $res = eval { $self->jse->decode( $self->rawdata ) }; |
|
35
|
|
|
|
|
|
|
warn $@ if $@; |
|
36
|
|
|
|
|
|
|
return $res; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
); |
|
39
|
|
|
|
|
|
|
has domain => is => 'ro', isa => 'Maybe[Str]'; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
has queue => (is => 'ro', isa => 'Object|Undef', weak_ref => 1); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
with 'DR::TarantoolQueue::JSE'; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$Carp::Internal{ (__PACKAGE__) }++; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
for my $m (qw(ack requeue bury dig unbury delete peek)) { |
|
49
|
5
|
|
|
5
|
|
34
|
no strict 'refs'; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
712
|
|
|
50
|
|
|
|
|
|
|
next if *{ __PACKAGE__ . "::$m" }{CODE}; |
|
51
|
|
|
|
|
|
|
*{ __PACKAGE__ . "::$m" } = sub { |
|
52
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
|
53
|
0
|
0
|
|
|
|
|
croak "Can't find queue for task" unless $self->queue; |
|
54
|
0
|
|
|
|
|
|
my $task = $self->queue->$m(task => $self); |
|
55
|
0
|
0
|
|
|
|
|
$self->_set_status($task->status) if $task; |
|
56
|
0
|
|
|
|
|
|
$task; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
for my $m (qw(get_meta)) { |
|
61
|
5
|
|
|
5
|
|
30
|
no strict 'refs'; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
2289
|
|
|
62
|
|
|
|
|
|
|
next if *{ __PACKAGE__ . "::$m" }{CODE}; |
|
63
|
|
|
|
|
|
|
*{ __PACKAGE__ . "::$m" } = sub { |
|
64
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
|
65
|
0
|
0
|
|
|
|
|
croak "Can't find queue for task" unless $self->queue; |
|
66
|
0
|
|
|
|
|
|
return $self->queue->$m(task => $self); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub tuple { |
|
72
|
0
|
|
|
0
|
0
|
|
my ($class, $tuple, $space, $queue) = @_; |
|
73
|
0
|
0
|
|
|
|
|
return undef unless $tuple; |
|
74
|
0
|
|
|
|
|
|
my $raw = $tuple->raw; |
|
75
|
0
|
|
|
|
|
|
return $class->new( |
|
76
|
|
|
|
|
|
|
id => $raw->[0], |
|
77
|
|
|
|
|
|
|
tube => $raw->[1], |
|
78
|
|
|
|
|
|
|
status => $raw->[2], |
|
79
|
|
|
|
|
|
|
rawdata => $raw->[3], |
|
80
|
|
|
|
|
|
|
space => $space, |
|
81
|
|
|
|
|
|
|
queue => $queue, |
|
82
|
|
|
|
|
|
|
); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub tuple_messagepack { |
|
86
|
0
|
|
|
0
|
0
|
|
my ($class, $tuple, $queue) = @_; |
|
87
|
0
|
0
|
|
|
|
|
return undef unless $tuple; |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
$class->new( |
|
90
|
|
|
|
|
|
|
id => $tuple->{id}, |
|
91
|
|
|
|
|
|
|
tube => $tuple->{tube}, |
|
92
|
|
|
|
|
|
|
status => $tuple->{status}, |
|
93
|
|
|
|
|
|
|
rawdata => $tuple->{data}, |
|
94
|
|
|
|
|
|
|
domain => $tuple->{domain}, |
|
95
|
0
|
|
|
|
|
|
queue => $queue, |
|
96
|
|
|
|
|
|
|
space => 'MegaQueue', |
|
97
|
|
|
|
|
|
|
); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub done { |
|
102
|
0
|
|
|
0
|
0
|
|
my ($self, %o) = @_; |
|
103
|
0
|
0
|
|
|
|
|
$o{data} = $self->data unless exists $o{data}; |
|
104
|
0
|
|
|
|
|
|
my $task = $self->queue->done(task => $self, %o); |
|
105
|
0
|
|
|
|
|
|
$self->_set_status( $task->status ); |
|
106
|
0
|
|
|
|
|
|
$self->_set_rawdata( $task->rawdata ); |
|
107
|
0
|
|
|
|
|
|
$self; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub release { |
|
111
|
0
|
|
|
0
|
0
|
|
my ($self, %o) = @_; |
|
112
|
0
|
|
|
|
|
|
my $task = $self->queue->release(task => $self, %o); |
|
113
|
0
|
|
|
|
|
|
$self->_set_status( $task->status ); |
|
114
|
0
|
|
|
|
|
|
$self; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |