| 1 | package Voldemort::Connection; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | =pod | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | Voldemort::Connection | ||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | =cut | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 1 | ▶ | use Moose::Role; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 1 | ▶ | use Voldemort::Message; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | =head1 METHODS | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | =head2 connect | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | Instructs a Connection object to connect. | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | =cut | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 1 | requires 'connect'; | |||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | =head2 discconect | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | Instructs a Connection object to disconnect. | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | =cut | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 1 | requires 'disconnect'; | |||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | =head2 select | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | Returns an IO::Select object of the current connection. | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | =cut | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 1 | has 'select' => ( | |||||||||||||||||||
| 39 | is => 'rw', | ||||||||||||||||||||
| 40 | isa => 'IO::Select' | ||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | =head2 is_connected | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | Moose boolean property indicating if the current connection should be available. | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | =cut | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 1 | has 'is_connected' => ( | |||||||||||||||||||
| 50 | isa => 'Bool', | ||||||||||||||||||||
| 51 | is => 'rw', | ||||||||||||||||||||
| 52 | default => 0, | ||||||||||||||||||||
| 53 | ); | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | =head2 socket | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | Moose IO::Socket property used for communication. | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | =cut | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 1 | has 'socket' => ( | |||||||||||||||||||
| 62 | is => 'rw', | ||||||||||||||||||||
| 63 | isa => 'IO::Socket::INET' | ||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | =head2 to | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | Moose string property in the format of host:port where to connect to. Required. | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | =cut | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 1 | has 'to' => ( | |||||||||||||||||||
| 73 | is => 'rw', | ||||||||||||||||||||
| 74 | isa => 'Str', | ||||||||||||||||||||
| 75 | required => 1, | ||||||||||||||||||||
| 76 | ); | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | =head2 delete_handler, put_handler, get_handler | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | Moose Voldemort::Message property handling gets, puts and deletes. | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | =cut | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | 1 | has 'get_handler' => ( | |||||||||||||||||||
| 86 | 'is' => 'rw', | ||||||||||||||||||||
| 87 | 'does' => 'Voldemort::Message' | ||||||||||||||||||||
| 88 | ); | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | 1 | has 'delete_handler' => ( | |||||||||||||||||||
| 92 | 'is' => 'rw', | ||||||||||||||||||||
| 93 | 'does' => 'Voldemort::Message' | ||||||||||||||||||||
| 94 | ); | ||||||||||||||||||||
| 95 | 1 | has 'put_handler' => ( | |||||||||||||||||||
| 96 | 'is' => 'rw', | ||||||||||||||||||||
| 97 | 'does' => 'Voldemort::Message' | ||||||||||||||||||||
| 98 | ); | ||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | 0 | ▶ | sub can_read { | ||||||||||||||||||
|
Subroutine
can_read: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 101 | 0 | my $self = shift; | |||||||||||||||||||
| 102 | 0 | return $self->select()->can_read(@_); | |||||||||||||||||||
| 103 | } | ||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | 0 | ▶ | sub can_write { | ||||||||||||||||||
|
Subroutine
can_write: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 106 | 0 | my $self = shift; | |||||||||||||||||||
| 107 | 0 | return $self->select->can_write(@_); | |||||||||||||||||||
| 108 | } | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | 0 | ▶ | sub flush { | ||||||||||||||||||
|
Subroutine
flush: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 111 | 0 | my $self = shift; | |||||||||||||||||||
| 112 | 0 | $self->socket()->flush(); | |||||||||||||||||||
| 113 | 0 | return; | |||||||||||||||||||
| 114 | } | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | 0 | ▶ | sub send { | ||||||||||||||||||
|
Subroutine
send: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 117 | 0 | my $self = shift; | |||||||||||||||||||
| 118 | 0 | ▶ | return $self->socket()->send(shift) || carp($!); | ||||||||||||||||||
|
Condition0%0/3
$self->socket->send(shift()) || carp($!)
MC/DC0%0/2
$self->socket->send(shift()) || carp($!)
$self->socket->send(shift())
carp($!)
Truth table0%0/3
A || B
A= $self->socket->send(shift())B= carp($!)
| |||||||||||||||||||||
| 119 | } | ||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | 0 | ▶ | sub recv { | ||||||||||||||||||
|
Subroutine
recv: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 122 | 0 | my $self = shift; | |||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | 0 | my $buffer; | |||||||||||||||||||
| 125 | 0 | $self->socket()->recv( $buffer, shift ); | |||||||||||||||||||
| 126 | 0 | return $buffer; | |||||||||||||||||||
| 127 | } | ||||||||||||||||||||
| 128 | |||||||||||||||||||||
| 129 | 1 | 1; | |||||||||||||||||||