Group
Extension

Matches 10

Message-Passing ( B/BO/BOBTFISH/Message-Passing-0.110.tar.gz, BOBTFISH, 2012; MetaCPAN )
Message-Passing/lib/Message/Passing/Filter/Encoder/JSON.pm ( view source; MetaCPAN )
package Message::Passing::Filter::Encoder::JSON;
use Moo;
use MooX::Types::MooseLike::Base qw/ Bool /;
use JSON qw/ to_json /;
use Scalar::Util qw/ blessed /;
use Try::Tiny;
use Message::Passing::Exce
an('to_hash')) {
                $message = $message->to_hash;
            }
        }
        to_json( $message, { utf8  => 1, $self->pretty ? (pretty => 1) : () } )
    }
    catch {
        $self->
:Role::Filter::Encoder::JSON - Encodes data structures as JSON for output

=head1 DESCRIPTION

This filter takes a hash ref or an object for a message, and serializes it to JSON.

Plain refs work as e
Message-Passing ( B/BO/BOBTFISH/Message-Passing-0.110.tar.gz, BOBTFISH, 2012; MetaCPAN )
Message-Passing/lib/Message/Passing/Filter/Decoder/JSON.pm ( view source; MetaCPAN )
package Message::Passing::Filter::Decoder::JSON;
use Moo;
use JSON qw/ from_json /;
use Try::Tiny;
use Message::Passing::Exception::Decoding;
use namespace::clean -except => 'meta';

with qw/
    Mess
/;

sub filter {
    my ($self, $message) = @_;
    try {
        ref($message) ? $message : from_json( $message, { utf8  => 1 } )
    }
    catch {
        $self->error->consume(Message::Passing::Exc
Passing::Role::Filter::Decoder::JSON

=head1 DESCRIPTION

Decodes string messages from JSON into data structures.

=head1 ATTRIBUTES

=head1 METHODS

=head2 filter

JSON decodes a message supplied as 
Message-Passing ( B/BO/BOBTFISH/Message-Passing-0.110.tar.gz, BOBTFISH, 2012; MetaCPAN )
Message-Passing/lib/Message/Passing.pm ( view source; MetaCPAN )
efault => 'Null' ),
    CLIComponent( name => 'decoder', default => 'JSON' ),
    CLIComponent( name => 'encoder', default => 'JSON' ),
    CLIComponent( name => 'error', default => 'STDERR' ),
    CL
IComponent( name => 'error_encoder', default => 'Message::Passing::Filter::Encoder::JSON' ),
    'Message::Passing::Role::Script';

option configfile => (
    is => 'ro',
    format => 's',
);

sub ge
=head2 BASIC PREMISE

You have data for discrete events, represented by a hash (and
serialized as JSON).

This could be a text log line, an audit record of an API
event, a metric emitted from your app
Message-Passing ( B/BO/BOBTFISH/Message-Passing-0.110.tar.gz, BOBTFISH, 2012; MetaCPAN )
Message-Passing/lib/Message/Passing/Output/File.pm ( view source; MetaCPAN )
ead2 filename

An attribute for the file name to write to.

=head2 consume

Consumes a message by JSON encoding it and printing it, followed by \n

=head1 SEE ALSO

L<Message::Passing>

=head1 SPONSOR
Message-Passing ( B/BO/BOBTFISH/Message-Passing-0.110.tar.gz, BOBTFISH, 2012; MetaCPAN )
Message-Passing/lib/Message/Passing/DSL.pm ( view source; MetaCPAN )
er within a chain.

    message_chain {
        encoder fooenc => ( output_to => 'out', class => 'JSON' );
        ....
    };

Class names will be assumed to prefixed with 'Message::Passing::Filter::
in a chain.

    message_chain {
        decoder zmq_decode => ( output_to => 'filter', class => 'JSON' );
        ....
    };

Class names will be assumed to prefixed with 'Message::Passing::Filter::
Message-Passing ( B/BO/BOBTFISH/Message-Passing-0.110.tar.gz, BOBTFISH, 2012; MetaCPAN )
Message-Passing/lib/Message/Passing/Manual/Cookbook.pod ( view source; MetaCPAN )
og::Dispatch;
    use Log::Dispatch::Message::Passing;
    use Message::Passing::Filter::Encoder::JSON;
    use Message::Passing::Output::ZeroMQ;

    my $log = Log::Dispatch->new;

    $log->add(Log:
egate_log',
        min_level => 'debug',
        output    => Message::Passing::Filter::Encoder::JSON->new(
            output_to => Message::Passing::Output::ZeroMQ->new(
                connect => 
Message-Passing ( B/BO/BOBTFISH/Message-Passing-0.110.tar.gz, BOBTFISH, 2012; MetaCPAN )
Message-Passing/lib/Message/Passing/Role/Output.pm ( view source; MetaCPAN )
package Message::Passing::Role::Output;
use Moo::Role;
use JSON qw/ to_json /;
use Scalar::Util qw/ blessed /;
#use namespace::clean -except => 'meta';

requires 'consume';

no Moo::Role;

1;

=head1 
Message-Passing ( B/BO/BOBTFISH/Message-Passing-0.110.tar.gz, BOBTFISH, 2012; MetaCPAN )
Message-Passing/lib/Message/Passing/Role/HasErrorChain.pm ( view source; MetaCPAN )
g::Output::STDERR';
    require_module 'Message::Passing::Filter::Encoder::JSON';
    Message::Passing::Filter::Encoder::JSON->new(
        output_to => Message::Passing::Output::STDERR->new,
    );
}
he error chain.

By default, this is a chain of:

=over

=item Message::Passing::Filter::Encoder::JSON

=item Message::Passing::Output::STDOUT

=back

=head1 WARNINGS

=head2 ERROR CHAINS CAN LOOP

If
Message-Passing ( B/BO/BOBTFISH/Message-Passing-0.110.tar.gz, BOBTFISH, 2012; MetaCPAN )
Message-Passing/lib/Message/Passing/Role/CLIComponent.pm ( view source; MetaCPAN )
s around before after with) ];
use MooX::Options;
use MooX::Types::MooseLike::Base qw/ Str /;
use JSON ();
use Try::Tiny qw/ try /;

sub make_variant {
    my ($class, $target_package, %arguments) = @
  my $str = shift;
            if (! ref $str) {
                try {
                    $str = JSON->new->relaxed->decode($str)
                };
            }
            $str;
        },
       
tional attribute called C<< "${name}_options" >> will also be added,
which coerces a hashref from JSON.

=head2 default

A default value for the main attribute. If this is not supplied, than the attri
Message-Passing ( B/BO/BOBTFISH/Message-Passing-0.110.tar.gz, BOBTFISH, 2012; MetaCPAN )
Message-Passing/lib/Message/Passing/Types.pm ( view source; MetaCPAN )
package Message::Passing::Types;
use MooseX::Types ();
use Moose::Util::TypeConstraints;
use JSON ();
use MooseX::Types::Moose qw/ Str HashRef ArrayRef /;
use MooseX::Types::Common::String qw/ NonEmpt
 -declare => [qw{
    Output_Type
    Input_Type
    Filter_Type
    Codec_Type
    Hash_from_JSON
    JSON_from_Hash
    ArrayOfStr
}];

role_type Input_Type, { role => 'Message::Passing::Role::Input
m_JSON,
    as HashRef;

coerce Hash_from_JSON,
  from NonEmptySimpleStr,
  via { try { JSON->new->relaxed->decode($_) } };

MooseX::Getopt::OptionTypeMap->add_option_type_to_map(
    Hash_from_JSON, 

Powered by Groonga
Maintained by Kenichi Ishigaki <ishigaki@cpan.org>. If you find anything, submit it on GitHub.