blib/lib/Dancer/Plugin/Queue/SQS.pm

filter: Statementstmt 67.6% 23 / 34 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 5 / 10 Podpod 0.0% 0 / 3 totaltotal 57.1% 28 / 49 CC 2 SCAR 8.2
CC
2
Cov
64%
get_msg
6.0
_build_queue
2.0
_build_sqs
2.0
CRAP 2.3
↑ Summary
1 package Dancer::Plugin::Queue::SQS;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Amazon::SQS::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 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 DESCRIPTION
17  
18 This module implements a L<Dancer::Plugin::Queue> using L<Amazon::SQS::Simple>.
19  
20 =head1 VERSION
21  
22 Version 1.0.0
23  
24 =cut
25  
26 1 our $VERSION = '1.0.0';
27  
28 =head1 ATTRIBUTES
29  
30 =head2 access_key
31  
32 AWS Access Key with SQS Permissions. Required.
33  
34 =cut
35  
36 1 has access_key => (
37 is => 'ro',
38 required => 1
39 );
40  
41 =head2 secret_key
42  
43 AWS Secret Key with SQS Permissions. Required.
44  
45 =cut
46  
47 1 has secret_key => (
48 is => 'ro',
49 required => 1
50 );
51  
52 =head2 queue_name
53  
54 Name of the collection that defines the queue. Defaults to 'queue'.
55  
56 =cut
57  
58 1 has queue_name => (
59 is => 'ro',
60 required => 1,
61 default => 'queue'
62 );
63  
64 =head2 queue
65  
66 The Amazon::SQS::Simple::Queue object that holds the queue. Built on demand from
67 other attributes.
68  
69 =cut
70  
71 1 has queue => (
72 is => 'lazy'
73 );
74  
75 =head2 sqs
76  
77 The Amazon::SQS::Simple object that holds the sqs connection. Built on demand from
78 other attributes.
79  
80 =cut
81  
82 1 has sqs => (
83 is => 'lazy'
84 );
85  
86 =for Pod::Coverage add_msg get_msg remove_msg
87  
88 =head1 USAGE
89  
90 See documentation for L<Dancer::Plugin::Queue>.
91  
92 =head1 SEE ALSO
93  
94 =over 4
95  
96 =item *
97  
98 L<Dancer::Plugin::Queue>
99  
100 =item *
101  
102 L<Amazon::SQS::Simple>
103  
104 =back
105  
106 =for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
107  
108 =head1 SUPPORT
109  
110 =head2 Bugs / Feature Requests
111  
112 Please report any bugs or feature requests through the issue tracker
113 at L<https://github.com/Casao/Dancer-Plugin-Queue-SQS/issues>.
114 You will be notified automatically of any progress on your issue.
115  
116 =head2 Source Code
117  
118 This is open source software. The code repository is available for
119 public review and contribution under the terms of the license.
120  
121 L<https://github.com/Casao/Dancer-Plugin-Queue-SQS>
122  
123 git clone https://github.com/Casao/Dancer-Plugin-Queue-SQS.git
124  
125 =head1 AUTHOR
126  
127 Colin Ewen <casao@cpan.org>
128  
129 =head1 COPYRIGHT AND LICENSE
130  
131 This software is Copyright (c) 2015 by Colin Ewen
132  
133 This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
134  
135 http://www.perlfoundation.org/artistic_license_2_0
136  
137 Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.
138  
139 If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.
140  
141 This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.
142  
143 This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.
144  
145 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146  
147 =cut
148  
149 0 ▶sub _build_queue {
Subroutine _build_queue: not called CC=1 SCAR=6.9
150 0 my ($self) = @_;
151 0 return $self->sqs->CreateQueue($self->queue_name);
152 }
153  
154 0 ▶sub _build_sqs {
Subroutine _build_sqs: not called CC=1 SCAR=6.9
155 0 my ($self) = @_;
156 0 return new Amazon::SQS::Simple($self->access_key, $self->secret_key);
157 }
158  
159 0 ▶sub add_msg {
Subroutine add_msg: not called CC=1 SCAR=6.9
Pod undocumented
160 0 my ($self, $data) = @_;
161 0 return $self->queue->SendMessage($data);
162 }
163  
164 0 ▶sub get_msg {
Subroutine get_msg: not called CC=2 SCAR=17.9
Pod undocumented
165 0 my ($self) = @_;
166 0 my $msg = $self->queue->ReceiveMessage();
167 0 ▶ return ( $msg, $msg->MessageBody() ) if $msg;
Branch: 1 branch
BranchTrueFalseTotal
if $msg 0 0 0
168 }
169  
170 0 ▶sub remove_msg {
Subroutine remove_msg: not called CC=1 SCAR=6.9
Pod undocumented
171 0 my ($self, $msg) = @_;
172 0 $self->queue->DeleteMessage($msg);
173 }
174  
175 1 1;
↑ Summary