line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dancer::Plugin::Queue::SQS; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
13807
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
34706
|
use Amazon::SQS::Simple; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Moo; |
9
|
|
|
|
|
|
|
use namespace::autoclean; |
10
|
|
|
|
|
|
|
with 'Dancer::Plugin::Queue::Role::Queue'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Dancer::Plugin::Queue::SQS - SQS Adapter for Dancer::Plugin::Queue |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 VERSION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Version 0.0.1 |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.0.1'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has secret_key => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
required => 1 |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has access_key => ( |
30
|
|
|
|
|
|
|
is => 'ro', |
31
|
|
|
|
|
|
|
required => 1 |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has queue_name => ( |
35
|
|
|
|
|
|
|
is => 'ro', |
36
|
|
|
|
|
|
|
required => 1 |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has queue => ( |
40
|
|
|
|
|
|
|
is => 'lazy' |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has sqs => ( |
44
|
|
|
|
|
|
|
is => 'lazy' |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _build_queue { |
48
|
|
|
|
|
|
|
my ($self) = @_; |
49
|
|
|
|
|
|
|
return $self->sqs->CreateQueue($self->queue_name); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _build_sqs { |
53
|
|
|
|
|
|
|
my ($self) = @_; |
54
|
|
|
|
|
|
|
return new Amazon::SQS::Simple($self->access_key, $self->secret_key); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub add_msg { |
58
|
|
|
|
|
|
|
my ($self, $data) = @_; |
59
|
|
|
|
|
|
|
return $self->queue->SendMessage($data); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub get_msg { |
63
|
|
|
|
|
|
|
my ($self) = @_; |
64
|
|
|
|
|
|
|
my $msg = $self->queue->ReceiveMessage(); |
65
|
|
|
|
|
|
|
return ( $msg, $msg->MessageBody() ) if $msg; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub remove_msg { |
69
|
|
|
|
|
|
|
my ($self, $msg) = @_; |
70
|
|
|
|
|
|
|
$self->queue->DeleteMessage($msg); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |