| 1 | package Message::Passing::AMQP::Role::DeclaresQueue; | ||||||||||
| 2 | 1 | ▶ | use Moo::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use Types::Standard qw( Bool Str HashRef ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use Scalar::Util qw/ weaken /; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | 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 | 0 | ▶ | default => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 15 | 0 | my $self = shift; | |||||||||
| 16 | 0 | $self->_queue->method_frame->queue; | |||||||||
| 17 | } | ||||||||||
| 18 | 1 | ); | |||||||||
| 19 | |||||||||||
| 20 | # FIXME - Should auto-build from _queue as above | ||||||||||
| 21 | 1 | has queue_durable => ( | |||||||||
| 22 | is => 'ro', | ||||||||||
| 23 | isa => Bool, | ||||||||||
| 24 | default => 1, | ||||||||||
| 25 | ); | ||||||||||
| 26 | |||||||||||
| 27 | 1 | has queue_exclusive => ( | |||||||||
| 28 | is => 'ro', | ||||||||||
| 29 | isa => Bool, | ||||||||||
| 30 | default => 0, | ||||||||||
| 31 | ); | ||||||||||
| 32 | |||||||||||
| 33 | 1 | has queue_auto_delete => ( | |||||||||
| 34 | is => 'ro', | ||||||||||
| 35 | isa => Bool, | ||||||||||
| 36 | default => 0, | ||||||||||
| 37 | ); | ||||||||||
| 38 | |||||||||||
| 39 | |||||||||||
| 40 | 1 | 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 | 0 | ▶ | default => sub { {} }, # E.g. 'x-ha-policy' => 'all' | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 50 | 1 | ); | |||||||||
| 51 | |||||||||||
| 52 | 0 | ▶ | after '_set_channel' => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||
| 53 | 0 | my $self = shift; | |||||||||
| 54 | 0 | 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 | 0 | ▶ | on_success => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 62 | 0 | $self->_set_queue(shift()); | |||||||||
| 63 | }, | ||||||||||
| 64 | 0 | ▶ | on_failure => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 65 | 0 | warn("Failed to get queue"); | |||||||||
| 66 | 0 | $self->_clear_channel; | |||||||||
| 67 | }, | ||||||||||
| 68 | 0 | ▶ | ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 69 | 1 | }; | |||||||||
| 70 | |||||||||||
| 71 | 1 | 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 | ||||||||||