| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
59054
|
use utf8; |
|
|
1
|
|
|
|
|
8
|
|
|
|
1
|
|
|
|
|
6
|
|
|
2
|
1
|
|
|
1
|
|
22
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
14
|
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
18
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
296
|
use DR::Tnt::FullCb; |
|
|
1
|
|
|
|
|
86
|
|
|
|
1
|
|
|
|
|
36
|
|
|
6
|
|
|
|
|
|
|
package DR::Tnt::Client::AE; |
|
7
|
1
|
|
|
1
|
|
6
|
use Mouse; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
4
|
|
|
8
|
1
|
|
|
1
|
|
273
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
45
|
|
|
9
|
1
|
|
|
1
|
|
740
|
use AnyEvent; |
|
|
1
|
|
|
|
|
4115
|
|
|
|
1
|
|
|
|
|
208
|
|
|
10
|
|
|
|
|
|
|
$Carp::Internal{ (__PACKAGE__) }++; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
with 'DR::Tnt::Role::Logging'; |
|
14
|
|
|
|
|
|
|
has host => is => 'ro', isa => 'Str', required => 1; |
|
15
|
|
|
|
|
|
|
has port => is => 'ro', isa => 'Str', required => 1; |
|
16
|
|
|
|
|
|
|
has user => is => 'ro', isa => 'Maybe[Str]'; |
|
17
|
|
|
|
|
|
|
has password => is => 'ro', isa => 'Maybe[Str]'; |
|
18
|
|
|
|
|
|
|
has reconnect_interval => is => 'ro', isa => 'Maybe[Num]'; |
|
19
|
|
|
|
|
|
|
has hashify_tuples => is => 'ro', isa => 'Bool', default => 0; |
|
20
|
|
|
|
|
|
|
has lua_dir => is => 'ro', isa => 'Maybe[Str]'; |
|
21
|
|
|
|
|
|
|
has utf8 => is => 'ro', isa => 'Bool', default => 1; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has _fcb => |
|
24
|
|
|
|
|
|
|
is => 'ro', |
|
25
|
|
|
|
|
|
|
isa => 'Object', |
|
26
|
|
|
|
|
|
|
handles => [ 'last_error' ], |
|
27
|
|
|
|
|
|
|
lazy => 1, |
|
28
|
|
|
|
|
|
|
builder => sub { |
|
29
|
|
|
|
|
|
|
my ($self) = @_; |
|
30
|
|
|
|
|
|
|
DR::Tnt::FullCb->new( |
|
31
|
|
|
|
|
|
|
logger => $self->logger, |
|
32
|
|
|
|
|
|
|
host => $self->host, |
|
33
|
|
|
|
|
|
|
port => $self->port, |
|
34
|
|
|
|
|
|
|
user => $self->user, |
|
35
|
|
|
|
|
|
|
password => $self->password, |
|
36
|
|
|
|
|
|
|
reconnect_interval => $self->reconnect_interval, |
|
37
|
|
|
|
|
|
|
hashify_tuples => $self->hashify_tuples, |
|
38
|
|
|
|
|
|
|
lua_dir => $self->lua_dir, |
|
39
|
|
|
|
|
|
|
driver => 'async', |
|
40
|
|
|
|
|
|
|
utf8 => $self->utf8, |
|
41
|
|
|
|
|
|
|
) |
|
42
|
|
|
|
|
|
|
}; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my @methods = qw( |
|
45
|
|
|
|
|
|
|
select |
|
46
|
|
|
|
|
|
|
update |
|
47
|
|
|
|
|
|
|
insert |
|
48
|
|
|
|
|
|
|
replace |
|
49
|
|
|
|
|
|
|
delete |
|
50
|
|
|
|
|
|
|
call_lua |
|
51
|
|
|
|
|
|
|
eval_lua |
|
52
|
|
|
|
|
|
|
ping |
|
53
|
|
|
|
|
|
|
auth |
|
54
|
|
|
|
|
|
|
get |
|
55
|
|
|
|
|
|
|
); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
for my $m (@methods) { |
|
58
|
1
|
|
|
1
|
|
6
|
no strict 'refs'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
282
|
|
|
59
|
|
|
|
|
|
|
*{ $m } = sub { |
|
60
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
61
|
0
|
|
|
|
|
|
unshift @_ => $m; |
|
62
|
0
|
|
|
|
|
|
$self->request(@_); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub request { |
|
68
|
0
|
|
|
0
|
0
|
|
my $cb = pop; |
|
69
|
0
|
|
|
|
|
|
my ($self, @args) = @_; |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my $m = $args[0]; |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
|
@args = ('select', @args[1, 2, 3], 1, 0, 'EQ') if $m eq 'get'; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$self->_fcb->request(@args, |
|
76
|
|
|
|
|
|
|
sub { |
|
77
|
0
|
|
|
0
|
|
|
my ($status, $message, $resp) = @_; |
|
78
|
0
|
0
|
|
|
|
|
unless ($status eq 'OK') { |
|
79
|
0
|
0
|
|
|
|
|
if ($m eq 'ping') { |
|
80
|
0
|
|
|
|
|
|
$cb->(0); |
|
81
|
0
|
|
|
|
|
|
return; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
0
|
|
|
|
|
|
$cb->(undef); |
|
84
|
0
|
|
|
|
|
|
return; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
goto $m; |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
ping: |
|
90
|
|
|
|
|
|
|
auth: |
|
91
|
0
|
|
|
|
|
|
$cb->(1); |
|
92
|
0
|
|
|
|
|
|
return; |
|
93
|
|
|
|
|
|
|
|
|
94
|
0
|
0
|
|
|
|
|
get: |
|
95
|
|
|
|
|
|
|
update: |
|
96
|
|
|
|
|
|
|
insert: |
|
97
|
|
|
|
|
|
|
replace: |
|
98
|
|
|
|
|
|
|
delete: |
|
99
|
|
|
|
|
|
|
$self->_log(error => |
|
100
|
|
|
|
|
|
|
'Method %s returned more than one result (%s items)', |
|
101
|
|
|
|
|
|
|
$m, |
|
102
|
|
|
|
|
|
|
scalar @$resp |
|
103
|
0
|
|
|
|
|
|
) if @$resp > 1; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
$cb->($resp->[0]); |
|
105
|
0
|
|
|
|
|
|
return; |
|
106
|
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
select: |
|
108
|
|
|
|
|
|
|
call_lua: |
|
109
|
|
|
|
|
|
|
eval_lua: |
|
110
|
0
|
|
|
|
|
|
$cb->($resp); |
|
|
0
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
return; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
0
|
|
|
|
|
|
); |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
__END__ |