Message::Router - Fast, simple message routing
use Message::Router qw(mroute mroute_config); sub main::handler1 { my %args = @_; #gets: # $args{message} # $args{route} # $args{routes} # $args{forward} print "$args{message}->{this}\n"; #from the transform print "$args{forward}->{x}\n"; #from the specific forward } mroute_config({ routes => [ { match => { a => 'b', }, forwards => [ { handler => 'main::handler1', x => 'y', }, ], transform => { this => 'that', }, } ], }); mroute({a => 'b'}); #prints 'that', and then 'y', per the handler1 sub mroute_config({ routes => { 10 => { match => { a => 'b', }, forwards => [ { handler => 'main::handler1', x => 'y', }, ], transform => { this => 'that', }, } ], }); mroute({a => 'b'}); #prints 'that', and then 'y', per the handler1 sub #same as the ARRAY based, but it uses the HASH keys in numerical order
This library allows fast, flexible and general message routing.
The config used by all mroute calls
Pass $message through the config; this will emit zero or more callbacks.
A config validator.
Short-circuiting
More flexible match and transform configuration forms
None known.
Copyright (c) 2012, 2013 Dana M. Diederich. All Rights Reserved.
Dana M. Diederich <dana@realms.org>
To install Message::Router, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Message::Router
CPAN shell
perl -MCPAN -e shell install Message::Router
For more information on module installation, please visit the detailed CPAN module installation guide.