| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MsgPack::RPC::Message::Request; |
|
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:YANICK'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: a MessagePack-RPC request |
|
4
|
|
|
|
|
|
|
$MsgPack::RPC::Message::Request::VERSION = '2.0.2'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
16
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
74
|
|
|
7
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
56
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
838
|
use MsgPack::RPC::Message::Response; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
74
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
15
|
use Moose; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
10
|
|
|
12
|
2
|
|
|
2
|
|
13158
|
use MooseX::MungeHas 'is_ro'; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
11
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
extends 'MsgPack::RPC::Message::Notification'; |
|
15
|
|
|
|
|
|
|
|
|
16
|
2
|
|
|
2
|
|
2091
|
use Promises qw/ deferred /; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
16
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $ID = 0; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has id => ( |
|
21
|
|
|
|
|
|
|
is => 'ro', |
|
22
|
|
|
|
|
|
|
isa => 'Int', |
|
23
|
|
|
|
|
|
|
lazy => 1, |
|
24
|
|
|
|
|
|
|
default => sub { ++$ID }, |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub response { |
|
28
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
29
|
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
0
|
MsgPack::RPC::Message::Response->new( |
|
31
|
|
|
|
|
|
|
id => $self->id, |
|
32
|
|
|
|
|
|
|
result => shift, |
|
33
|
|
|
|
|
|
|
); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub response_error { |
|
37
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
38
|
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
0
|
MsgPack::RPC::Message::Response->new( |
|
40
|
|
|
|
|
|
|
id => $self->id, |
|
41
|
|
|
|
|
|
|
error => shift, |
|
42
|
|
|
|
|
|
|
); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
2
|
|
|
2
|
0
|
33
|
sub is_request { 1} |
|
46
|
0
|
|
|
0
|
0
|
0
|
sub is_notification { 0} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub pack { |
|
49
|
3
|
|
|
3
|
0
|
8
|
my $self = shift; |
|
50
|
|
|
|
|
|
|
|
|
51
|
3
|
|
|
|
|
77
|
return [ 0, $self->id, $self->method, $self->params ]; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=pod |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=encoding UTF-8 |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 NAME |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
MsgPack::RPC::Message::Request - a MessagePack-RPC request |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 VERSION |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
version 2.0.2 |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
use MsgPack::RPC; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
my $rpc = MsgPack::RPC->new( io => '127.0.0.1:6543' ); |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
$rpc->emit( some_request => 'MsgPack::RPC::Message::Request', args => [ 1..5 ] ); |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Sub-class of L<MsgPack::RPC::Message> representing an incoming request. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 METHODS |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 new( args => $args, message_id => $id ) |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Accepts the same argument as L<MsgPack::RPC::Message>, plus C<message_id>, |
|
87
|
|
|
|
|
|
|
the id of the request. |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 response |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Returns a L<Promises::Deferred> that, once fulfilled, sends the response back with the provided arguments. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$rpc->subscribe( something => sub { |
|
94
|
|
|
|
|
|
|
my $request = shift; |
|
95
|
|
|
|
|
|
|
$request->response->resolve('a-okay'); |
|
96
|
|
|
|
|
|
|
}); |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 resp($args) |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Shortcut for |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
$request->response->resolve($args) |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 error($args) |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Shortcut for |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
$request->response->reject($args) |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 AUTHOR |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Yanick Champoux <yanick@cpan.org> |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This software is copyright (c) 2019, 2017, 2016, 2015 by Yanick Champoux. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
119
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |