line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Message::Passing::Output::ZeroMQ; |
2
|
1
|
|
|
1
|
|
1859
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
3
|
1
|
|
|
1
|
|
1337
|
use ZeroMQ ':all'; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use namespace::clean -except => 'meta'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
with qw/ |
7
|
|
|
|
|
|
|
Message::Passing::ZeroMQ::Role::HasASocket |
8
|
|
|
|
|
|
|
Message::Passing::Role::Output |
9
|
|
|
|
|
|
|
/; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has '+_socket' => ( |
12
|
|
|
|
|
|
|
handles => { |
13
|
|
|
|
|
|
|
'_zmq_send' => 'send', |
14
|
|
|
|
|
|
|
}, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _socket_type { 'PUB' } |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _build_socket_hwm { 10000 } |
20
|
|
|
|
|
|
|
sub _build_socket_swap { 1024*1024*1024 } |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub consume { |
23
|
|
|
|
|
|
|
my $self = shift; |
24
|
|
|
|
|
|
|
my $data = shift; |
25
|
|
|
|
|
|
|
$self->_zmq_send($data); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 NAME |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Message::Passing::Output::ZeroMQ - output messages to ZeroMQ. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 SYNOPSIS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
use Message::Passing::Output::ZeroMQ; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $logger = Message::Passing::Output::ZeroMQ->new; |
39
|
|
|
|
|
|
|
$logger->consume({data => { some => 'data'}, '@metadata' => 'value' }); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Or see Log::Dispatch::Message::Passing for a more 'normal' interface to |
42
|
|
|
|
|
|
|
# simple logging. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Or use directly on command line: |
45
|
|
|
|
|
|
|
message-passing --input STDIN --output ZeroMQ --output_options \ |
46
|
|
|
|
|
|
|
'{"connect":"tcp://192.168.0.1:5552"}' |
47
|
|
|
|
|
|
|
{"data":{"some":"data"},"@metadata":"value"} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DESCRIPTION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
A L ZeroMQ output class. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Can be used as part of a chain of classes with the L utility, or directly as |
54
|
|
|
|
|
|
|
a logger in normal perl applications. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
See L. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 METHODS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 consume ($msg) |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Sends a message, as-is. This means that you must have encoded the message to a string before |
65
|
|
|
|
|
|
|
sending it. The C utility will do this for you into JSON, or you can |
66
|
|
|
|
|
|
|
do it manually as shown in the example in L. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 SEE ALSO |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=over |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item L |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item L |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item L |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item L |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item L |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=back |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 SPONSORSHIP |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This module exists due to the wonderful people at Suretec Systems Ltd. |
87
|
|
|
|
|
|
|
who sponsored its development for its |
88
|
|
|
|
|
|
|
VoIP division called SureVoIP for use with |
89
|
|
|
|
|
|
|
the SureVoIP API - |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 AUTHOR, COPYRIGHT AND LICENSE |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
See L. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|