line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# You may distribute under the terms of either the GNU General Public License |
2
|
|
|
|
|
|
|
# or the Artistic License (the same terms as Perl itself) |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# (C) Paul Evans, 2014 -- leonerd@leonerd.org.uk |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Net::Async::Gearman; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
887
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
73
|
|
9
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
97
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
18
|
use base qw( IO::Async::Stream Protocol::Gearman ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
2132
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
C - use Gearman with L |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
This module provides an L-based wrapper around |
22
|
|
|
|
|
|
|
L. It shouldn't be used directly; see instead |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=over 2 |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=item * |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
L |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=back |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 METHODS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 $gearman->connect( %args ) ==> ( $gearman ) |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Connects to the server. Takes the same arguments as L's |
41
|
|
|
|
|
|
|
C method, but additionally sets a default service name of port 4730. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub connect |
46
|
|
|
|
|
|
|
{ |
47
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
48
|
0
|
|
|
|
|
0
|
my %args = @_; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
0
|
$self->SUPER::connect( |
51
|
|
|
|
|
|
|
service => "4730", |
52
|
|
|
|
|
|
|
%args, |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub new_future |
57
|
|
|
|
|
|
|
{ |
58
|
2
|
|
|
2
|
1
|
8314
|
my $self = shift; |
59
|
2
|
|
|
|
|
7
|
return $self->loop->new_future; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub send |
63
|
|
|
|
|
|
|
{ |
64
|
1
|
|
|
1
|
1
|
133
|
my $self = shift; |
65
|
1
|
|
|
|
|
4
|
my ( $bytes ) = @_; |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
|
|
11
|
$self->write( $bytes ); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# geaman_state is OK |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub on_read |
73
|
|
|
|
|
|
|
{ |
74
|
1
|
|
|
1
|
1
|
3900
|
my $self = shift; |
75
|
1
|
|
|
|
|
2
|
my ( $buffref, $eof ) = @_; |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
6
|
$self->Protocol::Gearman::on_read( $$buffref ); |
78
|
1
|
|
|
|
|
260
|
return 0; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 AUTHOR |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Paul Evans |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
0x55AA; |