line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id$ |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Copyright (c) 2007 Daisuke Maki <daisuke@endeworks.jp> |
4
|
|
|
|
|
|
|
# All rights reserved. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify |
7
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by |
8
|
|
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or |
9
|
|
|
|
|
|
|
# (at your option) any later version. |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
12
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
13
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14
|
|
|
|
|
|
|
# GNU General Public License for more details. |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
17
|
|
|
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package POE::Component::MessageQueue::Statistics::Publish::YAML; |
20
|
1
|
|
|
1
|
|
1467
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
21
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
22
|
1
|
|
|
1
|
|
5
|
use base qw(POE::Component::MessageQueue::Statistics::Publish); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
742
|
|
23
|
|
|
|
|
|
|
use Best [ qw(YAML::Syck YAML) ], qw(Dump); |
24
|
|
|
|
|
|
|
use File::Temp; |
25
|
|
|
|
|
|
|
use File::Copy qw(move); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub publish_file |
28
|
|
|
|
|
|
|
{ |
29
|
|
|
|
|
|
|
my ($self, $filename) = @_; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Be friendly to people who might be reading the file |
32
|
|
|
|
|
|
|
my $fh = File::Temp->new(UNLINK => 0); |
33
|
|
|
|
|
|
|
my %h = %{ $self->{statistics}->{statistics} }; |
34
|
|
|
|
|
|
|
eval { |
35
|
|
|
|
|
|
|
$fh->print( Dump( { %h, generated => scalar localtime } ) ); |
36
|
|
|
|
|
|
|
$fh->flush; |
37
|
|
|
|
|
|
|
move($fh->filename, $filename) or die "Failed to rename $fh to $filename: $!"; |
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
if (my $e = $@) { |
40
|
|
|
|
|
|
|
$fh->unlink_on_destroy( 1 ) if $fh; |
41
|
|
|
|
|
|
|
die $e; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub publish_handle |
46
|
|
|
|
|
|
|
{ |
47
|
|
|
|
|
|
|
my ($self, $handle) = @_; |
48
|
|
|
|
|
|
|
$handle->print( Dump( $self->{statistics}->{statistics} ) ); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 NAME |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
POE::Component::MessageQueue::Statistics::Publish::YAML - Publish Statistics In YAML Format |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 SYNOPSIS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
use POE::Component::MessageQueue::Statistics; |
62
|
|
|
|
|
|
|
use POE::Component::MessageQueue::Statistics::Publish::YAML; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# This is initialized elsewhere |
65
|
|
|
|
|
|
|
my $stats = POE::Component::MessageQueue::Statistics->new(); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $publish = POE::Component::MessageQueue::Statistics::Publish::YAML->new( |
68
|
|
|
|
|
|
|
output => \*STDOUT, |
69
|
|
|
|
|
|
|
statistics => $stats |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
$publish->publish(); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 DESCRIPTION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This module dumps the statistics information in YAML format |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 SEE ALSO |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Statistics>, |
80
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Statistics::Publish> |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 AUTHOR |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Daisuke Maki E<lt>daisuke@endeworks.jpE<gt> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |