line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AnyEvent::Beanstalk::Job; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$AnyEvent::Beanstalk::Job::VERSION = '1.142520'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
33
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
28979
|
|
7
|
5
|
|
|
5
|
|
47
|
use warnings; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
271
|
|
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
29
|
use base qw(Class::Accessor::Fast); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
7671
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw(id client buried reserved data error)); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
0
|
|
|
0
|
1
|
|
my $proto = shift; |
15
|
0
|
|
0
|
|
|
|
bless {@_}, ref($proto) || $proto; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub stats { |
19
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
20
|
0
|
|
|
|
|
|
my ($stats, $err) = $self->client->stats_job($self->id)->recv; |
21
|
0
|
0
|
|
|
|
|
return $self->{_stats} = $stats if $stats; |
22
|
0
|
|
0
|
|
|
|
$self->error($err || 'unknown'); |
23
|
0
|
|
|
|
|
|
return undef; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub delete { |
27
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
28
|
0
|
|
|
|
|
|
my ($ok, $err) = $self->client->delete($self->id)->recv; |
29
|
0
|
0
|
|
|
|
|
if ($ok) { |
30
|
0
|
|
|
|
|
|
$self->reserved(0); |
31
|
0
|
|
|
|
|
|
$self->buried(0); |
32
|
0
|
|
|
|
|
|
return 1; |
33
|
|
|
|
|
|
|
} |
34
|
0
|
|
0
|
|
|
|
$self->error($err || 'unknown'); |
35
|
0
|
|
|
|
|
|
return undef; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub touch { |
39
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
40
|
0
|
|
|
|
|
|
my ($ok, $err) = $self->client->touch($self->id)->recv; |
41
|
0
|
0
|
|
|
|
|
return 1 if $ok; |
42
|
0
|
|
0
|
|
|
|
$self->error($err || 'unknown'); |
43
|
0
|
|
|
|
|
|
return undef; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub peek { |
47
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
48
|
0
|
|
|
|
|
|
my ($job, $err) = $self->client->peek($self->id)->recv; |
49
|
0
|
0
|
|
|
|
|
if ($job) { |
50
|
0
|
|
|
|
|
|
$self->data($job->data); |
51
|
0
|
|
|
|
|
|
return 1; |
52
|
|
|
|
|
|
|
} |
53
|
0
|
|
0
|
|
|
|
$self->error($err || 'unknown'); |
54
|
0
|
|
|
|
|
|
return undef; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub release { |
58
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
59
|
0
|
|
|
|
|
|
my $opt = shift; |
60
|
0
|
|
|
|
|
|
my ($ok, $err) = $self->client->release($self->id, $opt)->recv; |
61
|
0
|
|
|
|
|
|
$self->reserved(0); |
62
|
0
|
0
|
|
|
|
|
return 1 if $ok; |
63
|
0
|
|
0
|
|
|
|
$self->error($err || 'unknown'); |
64
|
0
|
|
|
|
|
|
return undef; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub bury { |
68
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
69
|
0
|
|
|
|
|
|
my $opt = shift; |
70
|
0
|
|
|
|
|
|
my ($ok, $err) = $self->client->bury($self->id, $opt)->recv; |
71
|
0
|
0
|
|
|
|
|
if ($ok) { |
72
|
0
|
|
|
|
|
|
$self->reserved(0); |
73
|
0
|
|
|
|
|
|
$self->buried(1); |
74
|
0
|
|
|
|
|
|
return 1; |
75
|
|
|
|
|
|
|
} |
76
|
0
|
|
0
|
|
|
|
$self->error($err || 'unknown'); |
77
|
0
|
|
|
|
|
|
return undef; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# DEPRECATED! The proper method name is "args". |
81
|
0
|
|
|
0
|
0
|
|
sub decode { goto \&args; } |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub args { |
84
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
85
|
0
|
|
|
|
|
|
my $data = $self->data; |
86
|
0
|
0
|
|
|
|
|
return unless defined($data); |
87
|
0
|
|
|
|
|
|
$self->client->decoder->($data); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub tube { |
91
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
92
|
|
|
|
|
|
|
|
93
|
0
|
0
|
0
|
|
|
|
my $stats = $self->{_stats} || $self->stats |
94
|
|
|
|
|
|
|
or return undef; |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
$stats->tube; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub ttr { |
100
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
101
|
|
|
|
|
|
|
|
102
|
0
|
0
|
0
|
|
|
|
my $stats = $self->{_stats} || $self->stats |
103
|
|
|
|
|
|
|
or return undef; |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
$stats->ttr; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub priority { |
109
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
110
|
|
|
|
|
|
|
|
111
|
0
|
0
|
0
|
|
|
|
my $stats = $self->{_stats} || $self->stats |
112
|
|
|
|
|
|
|
or return undef; |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
$stats->pri; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
__END__ |