line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tak::Client; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
839
|
use Tak; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
490
|
use Tak::Request; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
5
|
1
|
|
|
1
|
|
6
|
use Moo; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has service => (is => 'ro', required => 1); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has curried => (is => 'ro', default => sub { [] }); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub curry { |
12
|
0
|
|
|
0
|
0
|
|
my ($self, @curry) = @_; |
13
|
0
|
|
|
|
|
|
(ref $self)->new(%$self, curried => [ @{$self->curried}, @curry ]); |
|
0
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
0
|
0
|
|
sub send { shift->receive(@_) } |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub receive { |
19
|
0
|
|
|
0
|
0
|
|
my ($self, @message) = @_; |
20
|
0
|
|
|
|
|
|
$self->service->receive(@{$self->curried}, @message); |
|
0
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub start { |
24
|
0
|
|
|
0
|
0
|
|
my ($self, $register, @payload) = @_; |
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
|
|
|
0
|
0
|
|
my ($self, $req, @payload) = @_; |
32
|
0
|
|
|
|
|
|
$self->service->start_request($req, @{$self->curried}, @payload); |
|
0
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
0
|
0
|
|
sub request_class { 'Tak::Request' } |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _new_request { |
38
|
0
|
|
|
0
|
|
|
my ($self, $args) = @_; |
39
|
0
|
|
|
|
|
|
$self->request_class->new($args); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub do { |
43
|
0
|
|
|
0
|
0
|
|
shift->result_of(@_)->get; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub result_of { |
47
|
0
|
|
|
0
|
0
|
|
my ($self, @payload) = @_; |
48
|
0
|
|
|
|
|
|
my $done; |
49
|
|
|
|
|
|
|
my $result; |
50
|
|
|
|
|
|
|
my $req = $self->start({ |
51
|
0
|
|
|
0
|
|
|
on_result => sub { $result = shift }, |
52
|
0
|
|
|
|
|
|
}, @payload); |
53
|
0
|
|
|
|
|
|
Tak->loop_until($result); |
54
|
0
|
|
|
|
|
|
return $result; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub clone_or_self { |
58
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
59
|
|
|
|
|
|
|
(ref $self)->new( |
60
|
|
|
|
|
|
|
service => $self->service->clone_or_self, |
61
|
0
|
|
|
|
|
|
curried => [ @{$self->curried} ], |
|
0
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |