line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Message::Passing::AMQP::Role::DeclaresQueue; |
2
|
1
|
|
|
1
|
|
581
|
use Moo::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
3
|
1
|
|
|
1
|
|
483
|
use Types::Standard qw( Bool Str HashRef ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
4
|
1
|
|
|
1
|
|
824
|
use Scalar::Util qw/ weaken /; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
46
|
|
5
|
1
|
|
|
1
|
|
8
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
with 'Message::Passing::AMQP::Role::HasAChannel'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has queue_name => ( |
10
|
|
|
|
|
|
|
is => 'ro', |
11
|
|
|
|
|
|
|
isa => Str, |
12
|
|
|
|
|
|
|
predicate => '_has_queue_name', |
13
|
|
|
|
|
|
|
lazy => 1, |
14
|
|
|
|
|
|
|
default => sub { |
15
|
|
|
|
|
|
|
my $self = shift; |
16
|
|
|
|
|
|
|
$self->_queue->method_frame->queue; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# FIXME - Should auto-build from _queue as above |
21
|
|
|
|
|
|
|
has queue_durable => ( |
22
|
|
|
|
|
|
|
is => 'ro', |
23
|
|
|
|
|
|
|
isa => Bool, |
24
|
|
|
|
|
|
|
default => 1, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has queue_exclusive => ( |
28
|
|
|
|
|
|
|
is => 'ro', |
29
|
|
|
|
|
|
|
isa => Bool, |
30
|
|
|
|
|
|
|
default => 0, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has queue_auto_delete => ( |
34
|
|
|
|
|
|
|
is => 'ro', |
35
|
|
|
|
|
|
|
isa => Bool, |
36
|
|
|
|
|
|
|
default => 0, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has _queue => ( |
41
|
|
|
|
|
|
|
is => 'ro', |
42
|
|
|
|
|
|
|
writer => '_set_queue', |
43
|
|
|
|
|
|
|
predicate => '_has_queue', |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
has queue_arguments => ( |
47
|
|
|
|
|
|
|
isa => HashRef, |
48
|
|
|
|
|
|
|
is => 'ro', |
49
|
|
|
|
|
|
|
default => sub { {} }, # E.g. 'x-ha-policy' => 'all' |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
after '_set_channel' => sub { |
53
|
|
|
|
|
|
|
my $self = shift; |
54
|
|
|
|
|
|
|
weaken($self); |
55
|
|
|
|
|
|
|
$self->_channel->declare_queue( |
56
|
|
|
|
|
|
|
arguments => $self->queue_arguments, |
57
|
|
|
|
|
|
|
durable => $self->queue_durable, |
58
|
|
|
|
|
|
|
exclusive => $self->queue_exclusive, |
59
|
|
|
|
|
|
|
auto_delete => $self->queue_auto_delete, |
60
|
|
|
|
|
|
|
$self->_has_queue_name ? (queue => $self->queue_name) : (), |
61
|
|
|
|
|
|
|
on_success => sub { |
62
|
|
|
|
|
|
|
$self->_set_queue(shift()); |
63
|
|
|
|
|
|
|
}, |
64
|
|
|
|
|
|
|
on_failure => sub { |
65
|
|
|
|
|
|
|
warn("Failed to get queue"); |
66
|
|
|
|
|
|
|
$self->_clear_channel; |
67
|
|
|
|
|
|
|
}, |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
}; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 NAME |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Message::Passing::AMQP::Role::DeclaresQueue - Role for instances which have an AMQP queue. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 queue_name |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Defines the queue name, defaults to the name returned by the server. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
The server may place restrictions on queue names it generates that |
84
|
|
|
|
|
|
|
make them unsuitable in scenarios involving server restarts. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Recommend explicitly defining the queue name in those cases. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 queue_durable |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Defines if the queue is durable, defaults to true. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 queue_exclusive |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Defines if the queue is exclusive, defaults to false. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 queue_arguments |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Defines queue arguments, defaults to an empty hashref. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 queue_auto_delete |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
If true, the queue is flagged as auto-delete, defaults to false. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 AUTHOR, COPYRIGHT AND LICENSE |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
See L<Message::Passing::AMQP>. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |