line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::MessageBus::Message; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
85
|
use 5.006; |
|
3
|
|
|
|
|
13
|
|
|
3
|
|
|
|
|
146
|
|
4
|
3
|
|
|
3
|
|
25
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
123
|
|
5
|
3
|
|
|
3
|
|
21
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
162
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Net::MessageBus::Message - Pure Perl generic message queue |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 0.08 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
3
|
|
25
|
use base qw(Class::Accessor); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
3229
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qw(type group sender payload)); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
This module implements a pure perl message bus message object |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Example : |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
use Net::MessageBus::Message; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $foo = Net::MessageBus::Message->new( |
33
|
|
|
|
|
|
|
type => 'event', |
34
|
|
|
|
|
|
|
payload => { some => 'complex strcture' }, |
35
|
|
|
|
|
|
|
sender => 'script1', |
36
|
|
|
|
|
|
|
group => 'backend', |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
... |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 new |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Creates a new Net::MessageBus::Message object |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
B |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=over |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item * type = A type assigned to the message |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item * payload = A complex perl structure / scalar but it cannot contain any objects |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item * sender = the name of the Net::MessageBus client that is sending the message |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item * group = the group to which this message belongs |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=back |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
B : |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my $foo = Net::MessageBus::Message->new( |
64
|
|
|
|
|
|
|
type => 'event', |
65
|
|
|
|
|
|
|
payload => { some => 'complex strcture' }, |
66
|
|
|
|
|
|
|
sender => 'script1', |
67
|
|
|
|
|
|
|
group => 'backend', |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub new { |
73
|
612
|
|
|
612
|
1
|
927
|
my $class = shift; |
74
|
612
|
|
|
|
|
688
|
my %params = %{shift()}; |
|
612
|
|
|
|
|
3157
|
|
75
|
|
|
|
|
|
|
|
76
|
612
|
|
|
|
|
4290
|
my $self = __PACKAGE__->SUPER::new({%params}); |
77
|
|
|
|
|
|
|
|
78
|
612
|
|
|
|
|
10771
|
return $self; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 type |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Returns the type of the message |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
B : |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $type = $Message->type(); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 sender |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Returns the sender of the message |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
B : |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $type = $Message->sender(); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 group |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Returns the group of the message |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
B : |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
my $type = $Message->group(); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 payload |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Returns the payload of the message |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
B : |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
my $type = $Message->payload(); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 Private methods |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 serialize |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Serializes the message for transport |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub serialize { |
123
|
207
|
|
|
207
|
1
|
264
|
my $self = shift; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
return { |
126
|
207
|
|
|
|
|
795
|
sender => $self->sender(), |
127
|
|
|
|
|
|
|
group => $self->group(), |
128
|
|
|
|
|
|
|
type => $self->type(), |
129
|
|
|
|
|
|
|
payload => $self->payload() |
130
|
|
|
|
|
|
|
}; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 AUTHOR |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Horea Gligan, C<< >> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 BUGS |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
140
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
141
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 SUPPORT |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
perldoc Net::MessageBus::Message |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
You can also look for information at: |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=over 4 |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
L |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
L |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item * CPAN Ratings |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
L |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item * Search CPAN |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
L |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=back |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Copyright 2012 Horea Gligan. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
184
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
185
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=cut |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
1; # End of Net::MessageBus::Message |