Mojolicious-Plugin-DirectoryQueue
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/DirectoryQueue.pm view on Meta::CPAN
package Mojolicious::Plugin::DirectoryQueue;
use Mojo::Base 'Mojolicious::Plugin';
use Mojo::JSON qw(decode_json encode_json);
use Directory::Queue;
use POSIX qw(chown);
our $VERSION = '0.01';
sub register {
my ($plugin, $app, $args) = @_;
$args->{path} ||= '/tmp/DirQueue';
my $dirq = Directory::Queue->new( path => $args->{path} );
my $config = $app->config;
if ( $config->{hypnotoad} and $config->{hypnotoad}->{user} ) {
my ($uid,$gid) = ( getpwnam($config->{hypnotoad}->{user}) )[2,3];
chown $uid, $gid, $args->{path};
}
$app->helper(
enqueue => sub {
my ($self, $args) = @_;
$dirq->add(encode_json($args));
},
);
$app->helper(
( run in 1.927 second using v1.01-cache-2.11-cpan-71847e10f99 )