[SCM] libmessage-passing-perl Debian packaging branch, master, updated. debian/0.111-3-14-g44f6e88

Tomas Doran bobtfish at bobtfish.net
Mon May 6 11:57:16 UTC 2013


The following commit has been merged in the master branch:
commit 199bd3a7160147d7af541222e1521ee5440f87fa
Author: Tomas Doran <bobtfish at bobtfish.net>
Date:   Sun Jun 10 21:49:33 2012 +0100

    Refactor building connection managers

diff --git a/TODO b/TODO
index 523d504..e34efed 100644
--- a/TODO
+++ b/TODO
@@ -1,14 +1,9 @@
 Need upload:
-    - Message::Passing
-    - Message::Passing::Redis *
-    - Message::Passing::Input::FreeSWITCH *
-    
     - Message::Passing::STOMP
     - Message::Passing::AMQP
 
 Code core/general:
     - Connection code cleanup
-    - Unify hostname and port parsing between adaptors - remove server..
     - Connect error handling
     - Global error logging
     - Generic blessed object serialize filter
diff --git a/lib/Message/Passing/Role/ConnectionManager.pm b/lib/Message/Passing/Role/ConnectionManager.pm
index ec83381..e2bbd67 100644
--- a/lib/Message/Passing/Role/ConnectionManager.pm
+++ b/lib/Message/Passing/Role/ConnectionManager.pm
@@ -10,17 +10,7 @@ sub BUILD {
     $self->connection;
 }
 
-has timeout => (
-    isa => 'Num',
-    is => 'ro',
-    default => sub { 30 },
-);
-
-has reconnect_after => (
-    isa => 'Num',
-    is => 'ro',
-    default => sub { 2 },
-);
+with 'Message::Passing::Role::HasTimeoutAndReconnectAfter';
 
 has _timeout_timer => (
     is => 'rw',
diff --git a/lib/Message/Passing/Role/HasAConnection.pm b/lib/Message/Passing/Role/HasAConnection.pm
index 04fcf3a..cdae747 100644
--- a/lib/Message/Passing/Role/HasAConnection.pm
+++ b/lib/Message/Passing/Role/HasAConnection.pm
@@ -3,7 +3,8 @@ use Moose::Role;
 use Moose::Util::TypeConstraints;
 use namespace::autoclean;
 
-requires '_build_connection_manager', 'connected';
+# requires qw/ _connection_manager_attributes _connection_manager_class /;
+requires 'connected';
 
 has connection_manager => (
     is => 'ro',
@@ -12,6 +13,19 @@ has connection_manager => (
     builder => '_build_connection_manager',
 );
 
+sub _build_connection_manager {
+    my $self = shift;
+    confess "Cannot auto-build this connection manager"
+        unless $self->can('_connection_manager_attributes')
+            && $self->can('_connection_manager_class');
+    my %attrs = map { $_ => $self->$_ } (@{ $self->_connection_manager_attributes }, qw/timeout reconnect_after/);
+    my $class = $self->_connection_manager_class;
+    Class::MOP::load_class($class);
+    $class->new(%attrs);
+}
+
+with 'Message::Passing::Role::HasTimeoutAndReconnectAfter';
+
 sub BUILD {}
 after BUILD => sub {
     my $self = shift;
diff --git a/lib/Message/Passing/Role/HasTimeoutAndReconnectAfter.pm b/lib/Message/Passing/Role/HasTimeoutAndReconnectAfter.pm
new file mode 100644
index 0000000..208bd91
--- /dev/null
+++ b/lib/Message/Passing/Role/HasTimeoutAndReconnectAfter.pm
@@ -0,0 +1,18 @@
+package Message::Passing::Role::HasTimeoutAndReconnectAfter;
+use Moose::Role;
+use namespace::autoclean;
+
+has timeout => (
+    isa => 'Num',
+    is => 'ro',
+    default => sub { 30 },
+);
+
+has reconnect_after => (
+    isa => 'Num',
+    is => 'ro',
+    default => sub { 2 },
+);
+
+1;
+

-- 
libmessage-passing-perl Debian packaging



More information about the Pkg-perl-cvs-commits mailing list