| 1 | package MR::IProto::Connection; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | MR::IProto::Connection - base communication class | ||
| 6 | |||
| 7 | =head1 DESCRIPTION | ||
| 8 | |||
| 9 | Base class for sync and async connections. | ||
| 10 | |||
| 11 | =cut | ||
| 12 | |||
| 13 | 1 | ▶ | use Mouse; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | |||
| 15 | =head1 server | ||
| 16 | |||
| 17 | =over | ||
| 18 | |||
| 19 | =item server | ||
| 20 | |||
| 21 | Instanse of L<MR::IProto::Cluster::Server>. | ||
| 22 | |||
| 23 | =cut | ||
| 24 | |||
| 25 | 1 | has server => ( | |
| 26 | is => 'ro', | ||
| 27 | isa => 'MR::IProto::Cluster::Server', | ||
| 28 | required => 1, | ||
| 29 | weak_ref => 1, | ||
| 30 | handles => [qw( | ||
| 31 | host | ||
| 32 | port | ||
| 33 | connect_timeout | ||
| 34 | timeout | ||
| 35 | tcp_nodelay | ||
| 36 | tcp_keepalive | ||
| 37 | max_parallel | ||
| 38 | _send_started | ||
| 39 | _recv_finished | ||
| 40 | _debug | ||
| 41 | _debug_dump | ||
| 42 | )], | ||
| 43 | ); | ||
| 44 | |||
| 45 | =back | ||
| 46 | |||
| 47 | =cut | ||
| 48 | |||
| 49 | 0 | ▶ | sub _pack_header { |
|
Subroutine
_pack_header: not called CC=1 SCAR=6.9
| |||
| 50 | 0 | my ($self, $msg, $length, $sync) = @_; | |
| 51 | 0 | return pack 'L3', $msg, $length, $sync; | |
| 52 | } | ||
| 53 | |||
| 54 | 0 | ▶ | sub _unpack_header { |
|
Subroutine
_unpack_header: not called CC=1 SCAR=6.9
| |||
| 55 | 0 | my ($self, $header) = @_; | |
| 56 | 0 | return unpack 'L3', $header; | |
| 57 | } | ||
| 58 | |||
| 59 | 0 | ▶ | sub _choose_sync { |
|
Subroutine
_choose_sync: not called CC=1 SCAR=6.9
| |||
| 60 | 0 | my ($self) = @_; | |
| 61 | 0 | return 1 + int rand 0xfffffffe; | |
| 62 | } | ||
| 63 | |||
| 64 | 1 | ▶ | no Mouse; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 65 | 1 | __PACKAGE__->meta->make_immutable(); | |
| 66 | |||
| 67 | 1 | 1; | |