Mojolicious::Plugin::Narada - Narada configuration plugin
# Mojolicious $self->plugin('Narada'); $self->plugin(Narada => (log => Log::Fast->global)); # Mojolicious::Lite plugin 'Narada'; plugin Narada => (log => Log::Fast->global); # Global timer package MyApp; sub startup { my $app = shift; Mojo::IOLoop->timer(0 => $app->proxy(sub { say 'Next tick.' })); } # Request-related timer package MyApp::MyController; sub myaction { my $c = shift; $c->render_later; Mojo::IOLoop->timer(1 => $c->weak_proxy(sub { say 'Alive' })); Mojo::IOLoop->timer(2 => $c->proxy(sub { $c->render(text => 'Delayed by 2 seconds!'); })); Mojo::IOLoop->timer(3 => $c->weak_proxy(sub { say 'Dead' })); }
Mojolicious::Plugin::Narada is a plugin that configure Mojolicious to work in Narada project management environment.
Also this plugin add helpers proxy and weak_proxy, and you MUST use them to wrap all callbacks you setup for handling delayed events like timers or I/O (both global in your app and related to requests in your actions).
proxy
weak_proxy
There is also one feature unrelated to Narada - if callback started by any action throw unhandled exception it will be sent to browser using same $c->reply->exception as it already works for actions without delayed response.
$c->reply->exception
Mojolicious default Mojo::Log replaced with MojoX::Log::Fast to support logging to project-local syslog daemon in addition to files. In most cases it works as drop-in replacement and doesn't require any modifications in user code.
Also it set $app->log->ident() to $c->req->url->path to ease log file analyse.
$app->log->ident()
$c->req->url->path
You should manually add these lines to ./you_app starting script before call to Mojolicious::Commands->start_app():
./you_app
Mojolicious::Commands->start_app()
use Narada::Config qw( get_config_line ); # mode should be set here because it's used before executing MyApp::startup() local $ENV{MOJO_MODE} = get_config_line('mode');
Config file config/cookie.secret automatically loaded and used to initialize $app->secrets() (each line of file became separate param).
config/cookie.secret
$app->secrets()
Config file config/basepath automatically loaded and used to fix $c->req->url->base->path and $c->req->url->path to guarantee their consistency in any environment:
config/basepath
$c->req->url->base->path
url->path doesn't contain base->path
url->path does have leading slash
url->base->path set to content of config/basepath
These config files automatically loaded from config/hypnotoad/* and used to initialize $app->config(hypnotoad):
config/hypnotoad/*
$app->config(hypnotoad)
listen proxy accepts workers
Also hypnotoad configured to keep it lock/pid files in var/.
var/
unlock() will be automatically called after all actions and callbacks, even if they throw unhandled exception.
unlock()
Mojolicious::Plugin::Narada supports the following options.
plugin Narada => (log => Log::Fast->global);
Value for MojoX::Log::Fast->new().
Mojolicious::Plugin::Narada inherits all methods from Mojolicious::Plugin and implements the following new ones.
$plugin->register(Mojolicious->new); $plugin->register(Mojolicious->new, {log => Log::Fast->global});
Register hooks in Mojolicious application.
Narada, MojoX::Log::Fast, Mojolicious.
No bugs have been reported.
Please report any bugs or feature requests through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mojolicious-Plugin-Narada. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Mojolicious-Plugin-Narada
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Mojolicious-Plugin-Narada
CPAN Ratings
http://cpanratings.perl.org/d/Mojolicious-Plugin-Narada
Search CPAN
http://search.cpan.org/dist/Mojolicious-Plugin-Narada/
Alex Efros <powerman@cpan.org>
<powerman@cpan.org>
Copyright 2013,2014-2015 Alex Efros <powerman@cpan.org>.
This program is distributed under the MIT (X11) License: http://www.opensource.org/licenses/mit-license.php
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
To install Mojolicious::Plugin::Narada, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::Narada
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::Narada
For more information on module installation, please visit the detailed CPAN module installation guide.