File Coverage

blib/lib/AnyEvent/RabbitMQ/Fork/Channel.pm
Criterion Covered Total %
statement 12 15 80.0
branch n/a
condition n/a
subroutine 4 5 80.0
pod n/a
total 16 20 80.0


line stmt bran cond sub pod time code
1             package AnyEvent::RabbitMQ::Fork::Channel;
2             $AnyEvent::RabbitMQ::Fork::Channel::VERSION = '0.6';
3             =head1 NAME
4              
5             AnyEvent::RabbitMQ::Fork::Channel - Facade over L
6              
7             =head1 SYNOPSIS
8              
9             my $ch = $rf->open_channel;
10             $ch->declare_exchange(exchange => 'test_exchange');
11              
12             =cut
13              
14 1     1   8 use Moo;
  1         3  
  1         13  
15 1     1   356 use Types::Standard qw(Int Object Bool);
  1         2  
  1         11  
16              
17 1     1   913 use namespace::clean;
  1         3  
  1         9  
18              
19             =head1 DESCRIPTION
20              
21             This module provides an API to L that is running in
22             a fork maintained by L. Note that this is a facade
23             and not a subclass. It does however attempt to honor the public interface of
24             the real thing.
25              
26             There are some undocumented features of the real module that are not implemented
27             here. I leave that as an excercise for the reader to discover. At such a time as
28             those features appear to become formalized, I will expose them here.
29              
30             =head1 ATTRIBUTES
31              
32             =over
33              
34             =item B Numerical ID assigned by the connection object and used in
35             coordination with the server.
36              
37             =item B Indicator if this channel is open for use.
38              
39             =item B Indicator if the server has sent a C frame as
40             a form of throttle control. Will be true if that is the case.
41              
42             =item B Indicator if the channel is in confirm mode, meaning the
43             server will Ack/Nack/Return every message published.
44              
45             =back
46              
47             =cut
48              
49             has id => (is => 'ro', isa => Int);
50             has is_open => (is => 'ro', isa => Bool, default => 0);
51             has is_active => (is => 'ro', isa => Bool, default => 0);
52             has is_confirm => (is => 'ro', isa => Bool, default => 0);
53             has connection => (
54             is => 'ro',
55             isa => Object,
56             weak_ref => 1,
57             handles => ['_delegate']
58             );
59              
60             =head1 METHODS
61              
62             Pretty well enumerated in L.
63              
64             =cut
65              
66             my @methods = qw(
67             open
68             close
69             declare_exchange
70             bind_exchange
71             unbind_exchange
72             delete_exchange
73             declare_queue
74             bind_queue
75             unbind_queue
76             purge_queue
77             delete_queue
78             publish
79             consume
80             cancel
81             get
82             ack
83             qos
84             confirm
85             recover
86             reject
87             select_tx
88             commit_tx
89             rollback_tx
90             );
91              
92             foreach my $method (@methods) {
93 1     1   519 no strict 'refs';
  1         9  
  1         118  
94             *$method = sub {
95 0     0     my $self = shift;
96 0           $self->_delegate($method => $self->id, @_);
97 0           return $self;
98             };
99             }
100              
101             =head1 AUTHOR
102              
103             William Cox
104              
105             =head1 COPYRIGHT
106              
107             Copyright (c) 2014, the above named author(s).
108              
109             =head1 LICENSE
110              
111             This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
112              
113             =cut
114              
115             1;