| 1 | # $Id: /mirror/coderepos/lang/perl/Mvalve/trunk/lib/Mvalve/Writer.pm 66313 2008-07-17T04:29:13.361349Z daisuke $ | ||||||||||||||
| 2 | |||||||||||||||
| 3 | package Mvalve::Writer; | ||||||||||||||
| 4 | 1 | ▶ | use Moose; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 1 | ▶ | use Mvalve::Const; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 1 | ▶ | use Mvalve::Types; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 1 | ▶ | use Mvalve::Message; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | |||||||||||||||
| 9 | extends 'Mvalve::Base'; | ||||||||||||||
| 10 | |||||||||||||||
| 11 | __PACKAGE__->meta->make_immutable; | ||||||||||||||
| 12 | |||||||||||||||
| 13 | 1 | ▶ | no Moose; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 14 | |||||||||||||||
| 15 | 0 | ▶ | sub insert { | ||||||||||||
|
Subroutine
insert: not called CC=4 SCAR=30.0
| |||||||||||||||
| 16 | 0 | my ($self, %args) = @_; | |||||||||||||
| 17 | |||||||||||||||
| 18 | 0 | my $message = $args{message}; | |||||||||||||
| 19 | |||||||||||||||
| 20 | 0 | my $qs = $self->queue_set; | |||||||||||||
| 21 | |||||||||||||||
| 22 | 0 | my %data = ( | |||||||||||||
| 23 | destination => $message->header( &Mvalve::Const::DESTINATION_HEADER ), | ||||||||||||||
| 24 | message => $message->serialize() | ||||||||||||||
| 25 | ); | ||||||||||||||
| 26 | |||||||||||||||
| 27 | $self->log( | ||||||||||||||
| 28 | action => "enqueue", | ||||||||||||||
| 29 | destination => $data{destination}, | ||||||||||||||
| 30 | 0 | ); | |||||||||||||
| 31 | |||||||||||||||
| 32 | # Choose one of the queues, depending on the headers | ||||||||||||||
| 33 | 0 | my $table; | |||||||||||||
| 34 | 0 | ▶ | if ($message->header( &Mvalve::Const::EMERGENCY_HEADER ) ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 35 | 0 | $table = $qs->choose_table( 'emergency' ); | |||||||||||||
| 36 | } elsif ($message->header( &Mvalve::Const::DURATION_HEADER ) ) { | ||||||||||||||
| 37 | 0 | return $self->defer(message => $message); | |||||||||||||
| 38 | } else { | ||||||||||||||
| 39 | 0 | $table = $qs->choose_table(); | |||||||||||||
| 40 | } | ||||||||||||||
| 41 | |||||||||||||||
| 42 | 0 | ▶ | Mvalve::trace( "insert message '" . $message->id() . "' to $table" ) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 43 | if &Mvalve::Const::MVALVE_TRACE; | ||||||||||||||
| 44 | |||||||||||||||
| 45 | 0 | $self->q_insert( | |||||||||||||
| 46 | table => $table, | ||||||||||||||
| 47 | data => \%data, | ||||||||||||||
| 48 | ); | ||||||||||||||
| 49 | } | ||||||||||||||
| 50 | |||||||||||||||
| 51 | 1; | ||||||||||||||
| 52 | |||||||||||||||
| 53 | __END__ | ||||||||||||||