File Coverage

blib/lib/SQS/Worker/SNS.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package SQS::Worker::SNS;
2 1     1   407 use Moose::Role;
  1         2  
  1         6  
3 1     1   5135 use SNS::Notification;
  1         47665  
  1         32  
4 1     1   6 use JSON::MaybeXS;
  1         2  
  1         210  
5              
6             around process_message => sub {
7             my ($orig, $self, $message) = @_;
8              
9             my $body;
10             eval {
11             $body = decode_json($message->Body)
12             };
13             if ($@) {
14             $self->log->error("Worker::SNS Error decoding JSON body in message " . $message->ReceiptHandle . ": " . $@ . " for content " . $message->Body);
15             die $@;
16             } else {
17             die "SNS body should parse to a hashref" if (ref($body) ne 'HASH');
18             my $sns = eval { SNS::Notification->new($body) };
19             if ($@){
20             die "SNS Worker couldn't convert the message to a SNS::Notification: $@";
21             } else {
22             return $self->$orig($sns);
23             }
24             }
25             };
26              
27             1;