| 1 | # $Id$ | ||||||||||||
| 2 | |||||||||||||
| 3 | package Queue::Q4M::Status; | ||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 3 | ▶ | use DBI; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 3 | ▶ | use Carp(); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | 0 | ▶ | sub fetch { | ||||||||||
|
Subroutine
fetch: not called CC=5 SCAR=31.4
Pod
documented
| |||||||||||||
| 9 | # Black magic. Since I don't know if the parameters will be the same | ||||||||||||
| 10 | # for every future release of Q4M, I'll just create a cached | ||||||||||||
| 11 | # anonymous class via moose. Wicked! | ||||||||||||
| 12 | |||||||||||||
| 13 | 0 | my $class = shift; | |||||||||||
| 14 | 0 | ▶ | my $dbh = shift || Carp::confess("Q4M requires a database handle"); | ||||||||||
|
Condition0%0/2
shift() || Carp::confess('Q4M requires a database handle')
MC/DC0%0/1
shift() || Carp::confess('Q4M requires a database handle')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||
| 15 | |||||||||||||
| 16 | 0 | my $sth = $dbh->prepare( "SHOW ENGINE QUEUE STATUS" ); | |||||||||||
| 17 | |||||||||||||
| 18 | 0 | $sth->execute(); | |||||||||||
| 19 | 0 | my %attributes; | |||||||||||
| 20 | |||||||||||||
| 21 | 0 | my ($dummy1, $dummy2, $status); | |||||||||||
| 22 | 0 | $sth->bind_columns(\($dummy1, $dummy2, $status)); | |||||||||||
| 23 | 0 | $sth->fetchrow_arrayref; | |||||||||||
| 24 | 0 | $sth->finish; | |||||||||||
| 25 | |||||||||||||
| 26 | # now parse the status | ||||||||||||
| 27 | 0 | ▶ | { no strict 'refs'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||
| 28 | 0 | foreach my $line (split(/\r?\n/, $status)) { | |||||||||||
| 29 | 0 | ▶ | next unless $line =~ /^([\w_]+)\s+(\d+)$/; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 30 | |||||||||||||
| 31 | 0 | my ($name, $value) = ($1, $2); | |||||||||||
| 32 | 0 | ▶ | if (! defined &{$class.'::'.$name}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 33 | 0 | ▶ | *{$class.'::'.$name} = sub { shift->{$name} }; | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 34 | } | ||||||||||||
| 35 | 0 | $attributes{$1} = $2; | |||||||||||
| 36 | } | ||||||||||||
| 37 | } | ||||||||||||
| 38 | 0 | return bless {%attributes}, $class; | |||||||||||
| 39 | } | ||||||||||||
| 40 | |||||||||||||
| 41 | 3 | 1; | |||||||||||
| 42 | |||||||||||||
| 43 | __END__ | ||||||||||||