[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:40 UTC 2013


The following commit has been merged in the master branch:
commit 4cd92757a176a837fa55febb34c2ef7a32f559e3
Author: Tomas Doran <bobtfish at bobtfish.net>
Date:   Sun Aug 26 10:31:21 2012 +0100

    Make error chain encoding be universal.
    
    Add options to CLI scripts for that also

diff --git a/Changes b/Changes
index 89b6e5a..74a4496 100644
--- a/Changes
+++ b/Changes
@@ -4,6 +4,8 @@
   - Make default error chain do JSON encoding on errors so that they're
     readable.
 
+  - Make CLI error chain have options for the error encoder.
+
 0.101
   - Fix daemonization features provided by Message::Passing::Role::Script
     to work on the command line again by exlicitly using MooX::Options
diff --git a/TODO b/TODO
index c736abe..80419ab 100644
--- a/TODO
+++ b/TODO
@@ -4,6 +4,7 @@ Code core/general:
     - Global registry and DSL support for connection managers
     - Connection sharing
     - Connect timeout strategies
+    - Better documentation for error chain.
 
 Specific adaptors
     - AMQP needs a lot of work
diff --git a/lib/Message/Passing.pm b/lib/Message/Passing.pm
index 969d610..dce5cf4 100644
--- a/lib/Message/Passing.pm
+++ b/lib/Message/Passing.pm
@@ -33,6 +33,7 @@ with
     CLIComponent( name => 'decoder', default => 'JSON' ),
     CLIComponent( name => 'encoder', default => 'JSON' ),
     CLIComponent( name => 'error', default => 'STDERR' ),
+    CLIComponent( name => 'error_encoder', default => 'Message::Passing::Filter::Encoder::JSON' ),
     'Message::Passing::Role::Script';
 
 option configfile => (
@@ -53,8 +54,12 @@ sub build_chain {
     my $self = shift;
     message_chain {
         error_log(
-            %{ $self->error_options },
-            class => $self->error,
+            %{ $self->error_encoder_options },
+            class => $self->error_encoder,
+            output_to => output error => (
+                %{ $self->error_options },
+                class => $self->error,
+            ),
         );
         output output => (
             %{ $self->output_options },
diff --git a/lib/Message/Passing/DSL/Factory.pm b/lib/Message/Passing/DSL/Factory.pm
index 5cb19c7..105739f 100644
--- a/lib/Message/Passing/DSL/Factory.pm
+++ b/lib/Message/Passing/DSL/Factory.pm
@@ -6,7 +6,7 @@ use Message::Passing::Output::STDERR;
 use Carp qw/ confess /;
 use Scalar::Util qw/ blessed /;
 use Module::Runtime qw/ require_module /;
-use namespace::clean -except => 'meta';
+use namespace::clean -except => [qw/ meta _build_default_error_chain /];
 
 sub expand_class_name {
     my ($self, $type, $name) = @_;
@@ -35,17 +35,17 @@ sub set_error {
     my ($self, %opts) = @_;
     my $class = delete $opts{class}
         || confess("Class name needed");
-    $class = $self->expand_class_name('Output', $class);
     require_module($class);
     $self->_set_error($class->new(%opts));
 }
 
+use Message::Passing::Role::HasErrorChain;
+*_build_default_error_chain = \&Message::Passing::Role::HasErrorChain::_build_default_error_chain;
 has error => (
     is => 'ro',
     writer => '_set_error',
-    default => sub {
-        Message::Passing::Output::STDERR->new;
-    }
+    lazy => 1,
+    builder => '_build_default_error_chain',
 );
 
 sub make {
diff --git a/lib/Message/Passing/Role/HasErrorChain.pm b/lib/Message/Passing/Role/HasErrorChain.pm
index 3b807d6..0181845 100644
--- a/lib/Message/Passing/Role/HasErrorChain.pm
+++ b/lib/Message/Passing/Role/HasErrorChain.pm
@@ -5,16 +5,18 @@ use namespace::clean -except => 'meta';
 
 has error => (
     is => 'ro',
-    default => sub {
-        require_module 'Message::Passing::Output::STDERR';
-        require_module 'Message::Passing::Filter::Encoder::JSON';
-        Message::Passing::Filter::Encoder::JSON->new(
-            output_to => Message::Passing::Output::STDERR->new,
-        );
-    },
     lazy => 1,
+    builder => '_build_default_error_chain',
 );
 
+sub _build_default_error_chain {
+    require_module 'Message::Passing::Output::STDERR';
+    require_module 'Message::Passing::Filter::Encoder::JSON';
+    Message::Passing::Filter::Encoder::JSON->new(
+        output_to => Message::Passing::Output::STDERR->new,
+    );
+}
+
 1;
 
 =head1 NAME

-- 
libmessage-passing-perl Debian packaging



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