| 1 | package Tak::Client; | ||
| 2 | |||
| 3 | 1 | ▶ | use Tak; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use Tak::Request; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 1 | has service => (is => 'ro', required => 1); | |
| 8 | |||
| 9 | 0 | ▶ | has curried => (is => 'ro', default => sub { [] }); |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 10 | |||
| 11 | sub curry { | ||
| 12 | 0 | ▶ | my ($self, @curry) = @_; |
|
Subroutine
curry: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 13 | 0 | (ref $self)->new(%$self, curried => [ @{$self->curried}, @curry ]); | |
| 14 | } | ||
| 15 | |||
| 16 | 0 | ▶ | sub send { shift->receive(@_) } |
|
Subroutine
send: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 17 | |||
| 18 | sub receive { | ||
| 19 | 0 | ▶ | my ($self, @message) = @_; |
|
Subroutine
receive: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 20 | 0 | $self->service->receive(@{$self->curried}, @message); | |
| 21 | } | ||
| 22 | |||
| 23 | sub start { | ||
| 24 | 0 | ▶ | my ($self, $register, @payload) = @_; |
|
Subroutine
start: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 25 | 0 | my $req = $self->_new_request($register); | |
| 26 | 0 | $self->start_request($req, @payload); | |
| 27 | 0 | return $req; | |
| 28 | } | ||
| 29 | |||
| 30 | sub start_request { | ||
| 31 | 0 | ▶ | my ($self, $req, @payload) = @_; |
|
Subroutine
start_request: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 32 | 0 | $self->service->start_request($req, @{$self->curried}, @payload); | |
| 33 | } | ||
| 34 | |||
| 35 | 0 | ▶ | sub request_class { 'Tak::Request' } |
|
Subroutine
request_class: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 36 | |||
| 37 | sub _new_request { | ||
| 38 | 0 | ▶ | my ($self, $args) = @_; |
|
Subroutine
_new_request: not called CC=1 SCAR=6.9
| |||
| 39 | 0 | $self->request_class->new($args); | |
| 40 | } | ||
| 41 | |||
| 42 | sub do { | ||
| 43 | 0 | ▶ | shift->result_of(@_)->get; |
|
Subroutine
do: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 44 | } | ||
| 45 | |||
| 46 | sub result_of { | ||
| 47 | 0 | ▶ | my ($self, @payload) = @_; |
|
Subroutine
result_of: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 48 | 0 | my $done; | |
| 49 | my $result; | ||
| 50 | my $req = $self->start({ | ||
| 51 | 0 | ▶ | on_result => sub { $result = shift }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 52 | 0 | }, @payload); | |
| 53 | 0 | Tak->loop_until($result); | |
| 54 | 0 | return $result; | |
| 55 | } | ||
| 56 | |||
| 57 | sub clone_or_self { | ||
| 58 | 0 | ▶ | my ($self) = @_; |
|
Subroutine
clone_or_self: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 59 | (ref $self)->new( | ||
| 60 | service => $self->service->clone_or_self, | ||
| 61 | 0 | curried => [ @{$self->curried} ], | |
| 62 | ); | ||
| 63 | } | ||
| 64 | |||
| 65 | 1 | 1; | |