MrGamoo/API/HB.pm untested

filter: Statementstmt 0.0% 0 / 37 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 49 CC 2 SCAR 10.3
CC
2
Cov
0%
handler
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.8
1 # -*- perl -*-
2  
3 # Copyright (c) 2009 AdCopy
4 # Author: Jeff Weisberg
5 # Created: 2009-Dec-21 17:08 (EST)
6 # Function: respond to heartbeat requests
7 #
8 # $Id: HB.pm,v 1.1 2010/11/01 18:41:51 jaw Exp $
9  
10 package AC::MrGamoo::API::HB;
11 use AC::MrGamoo::Debug 'hb';
12 use AC::MrGamoo::Config;
13 use AC::MrGamoo::Stats;
14 use AC::MrGamoo::About;
15 use AC::MrGamoo::MySelf;
16  
17 use Sys::Hostname;
18  
19 require 'AC/protobuf/heartbeat.pl';
20 use strict;
21  
22 my $HOSTNAME = hostname();
23  
24 sub handler {
25 my $class = shift;
26 my $io = shift;
27 my $proto = shift;
28 my $req = shift;
29 my $content = shift;
30  
31 unless( $proto->{want_reply} ){
32 $io->shut();
33 return;
34 }
35  
36 my $response = AC::MrGamoo::Protocol->encode_reply( {
37 type => 'heartbeat_request',
38 msgid => $proto->{msgid},
39 is_reply => 1,
40 }, {
41 status_code => 200,
42 status_message => 'Honky Dory',
43 hostname => $HOSTNAME,
44 subsystem => 'mrgamoo',
45 environment => conf_value('environment'),
46 port => my_port(),
47 timestamp => time(),
48 sort_metric => loadave(),
49 server_id => my_server_id(),
50 process_id => $$,
51 } );
52  
53 debug("sending hb reply");
54 $io->write_and_shut( $response );
55  
56 }
57  
58  
59  
60 1;