NAME
Message::Passing::DSL - An easy way to make chains of Message::Passing components.
SYNOPSIS
package mylogcollectorscript;
use Message::Passing::DSL;
with 'MooseX::GetOpt',
'Message::Passing::Role::Script';
has socket_bind => (
is => 'ro',
isa => 'Str',
default => 'tcp://*:5558',
);
sub build_chain {
my $self = shift;
log_chain {
output console => (
class => 'STDOUT',
);
input zmq => (
class => 'ZeroMQ',
output_to => 'console',
socket_bind => $self->socket_bind,
);
};
}
__PACKAGE__->start unless caller;
1;
DESCRIPTION
This module provides a simple to use helper system for writing scripts which implement a Message::Passing server, like the built in message-pass script.
FUNCTIONS
log_chain
Constructs a log chain (i.e. a series of log objects feeding into each other), warns about any unused parts of the chain, and returns the chain head (i.e. the input class).
Maintains a registry / factory for the log classes, which is used to allow the resolving of symbolic names in the output_to key to function.
See example in the SYNOPSIS, and details on the other functions below.
output
Constructs a named output within a chain.
log_chain {
output foo => ( class => 'STDOUT' );
....
};
Class names will be assumed to prefixed with 'Log::Stash::Output::', unless you prefix the class with + e.g. +My::Own::Output::Class
encoder
Constructs a named encoder within a chain.
log_chain {
encoder fooenc => ( output_to => 'out', class => 'JSON' );
....
};
Class names will be assumed to prefixed with 'Log::Stash::Filter::Encoder::', unless you prefix the class with + e.g. +My::Own::Encoder::Class
filter
Constructs a named filter (which can act as both an output and an input) within a chain.
log_chain {
...
filter bar => ( output_to => 'fooenc', class => 'Null' );
...
};
Class names will be assumed to prefixed with 'Log::Stash::Filter::', unless you prefix the class with + e.g. +My::Own::Filter::Class
decoder
Constructs a named decoder within a chain.
log_chain {
decoder zmq_decode => ( output_to => 'filter', class => 'JSON' );
....
};
Class names will be assumed to prefixed with 'Log::Stash::Filter::Decoder::', unless you prefix the class with + e.g. +My::Own::Encoder::Class
input
The last thing in a chain - produces data which gets consumed.
log_chain {
...
input zmq => ( output_to => 'zmq_decode', class => 'ZeroMQ', bind => '...' );
....
}
Class names will be assumed to prefixed with 'Log::Stash::Output::', unless you prefix the class with + e.g. +My::Own::Output::Class
run_log_server
This enters the event loop and causes log events to be consumed and processed.
Can be passed a log_chain to run, although this is entirely optional (as all log chains which are still in scope will run when the event loop is entered).
SPONSORSHIP
This module exists due to the wonderful people at Suretec Systems Ltd. <http://www.suretecsystems.com/> who sponsored its development for its VoIP division called SureVoIP <http://www.surevoip.co.uk/> for use with the SureVoIP API - <http://www.surevoip.co.uk/support/wiki/api_documentation>
AUTHOR, COPYRIGHT AND LICENSE
See Message::Passing.