| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# This file is part of Riak-Light |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# This software is copyright (c) 2013 by Weborama. |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
|
7
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
## no critic (RequireUseStrict, RequireUseWarnings) |
|
10
|
|
|
|
|
|
|
package Riak::Light::Driver; |
|
11
|
|
|
|
|
|
|
{ |
|
12
|
|
|
|
|
|
|
$Riak::Light::Driver::VERSION = '0.12'; |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
## use critic |
|
15
|
|
|
|
|
|
|
|
|
16
|
15
|
|
|
15
|
|
52681
|
use English qw( -no_match_vars ); |
|
|
15
|
|
|
|
|
64340
|
|
|
|
15
|
|
|
|
|
157
|
|
|
17
|
15
|
|
|
15
|
|
14655
|
use Riak::Light::Connector; |
|
|
15
|
|
|
|
|
65
|
|
|
|
15
|
|
|
|
|
507
|
|
|
18
|
15
|
|
|
15
|
|
125
|
use Moo; |
|
|
15
|
|
|
|
|
28
|
|
|
|
15
|
|
|
|
|
75
|
|
|
19
|
15
|
|
|
15
|
|
4940
|
use Types::Standard -types; |
|
|
15
|
|
|
|
|
32
|
|
|
|
15
|
|
|
|
|
177
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# ABSTRACT: Riak Driver, deal with the binary protocol |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has connector => ( is => 'ro', required => 1 ); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub BUILDARGS { |
|
26
|
19
|
|
|
19
|
0
|
19682
|
my ( undef, %args ) = @_; |
|
27
|
|
|
|
|
|
|
|
|
28
|
19
|
100
|
|
|
|
135
|
if ( exists $args{socket} ) { |
|
29
|
16
|
|
|
|
|
564
|
my $connector = Riak::Light::Connector->new( socket => $args{socket} ); |
|
30
|
|
|
|
|
|
|
|
|
31
|
16
|
|
|
|
|
8537
|
$args{connector} = $connector; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
19
|
|
|
|
|
517
|
+{%args}; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub perform_request { |
|
38
|
21
|
|
|
21
|
0
|
576
|
my ( $self, %request ) = @_; |
|
39
|
|
|
|
|
|
|
|
|
40
|
21
|
|
|
|
|
62
|
my $request_body = $request{body}; |
|
41
|
21
|
|
|
|
|
52
|
my $request_code = $request{code}; |
|
42
|
|
|
|
|
|
|
|
|
43
|
21
|
|
|
|
|
227
|
my $message = pack( 'c a*', $request_code, $request_body ); |
|
44
|
|
|
|
|
|
|
|
|
45
|
21
|
|
|
|
|
549
|
$self->connector->perform_request($message); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub read_response { |
|
49
|
16
|
|
|
16
|
0
|
342
|
my ($self) = @_; |
|
50
|
16
|
100
|
|
|
|
274
|
my $response = $self->connector->read_response() |
|
51
|
|
|
|
|
|
|
or return $self->_parse_error(); |
|
52
|
8
|
|
|
|
|
172
|
$self->_parse_response($response); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _parse_response { |
|
56
|
8
|
|
|
8
|
|
68
|
my ( $self, $response ) = @_; |
|
57
|
8
|
|
|
|
|
134
|
my ( $code, $body ) = unpack( 'c a*', $response ); |
|
58
|
|
|
|
|
|
|
|
|
59
|
8
|
|
|
|
|
273
|
{ code => $code, body => $body, error => undef }; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _parse_error { |
|
63
|
8
|
|
100
|
8
|
|
385
|
{ code => -1, body => undef, error => $ERRNO || "Socket Closed" }; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=pod |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 NAME |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Riak::Light::Driver - Riak Driver, deal with the binary protocol |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 VERSION |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
version 0.12 |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Internal class |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 AUTHORS |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=over 4 |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item * |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Tiago Peczenyj |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item * |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Damien Krotkine |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=back |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Weborama. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
102
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |