Daemonise::Plugin::JobQueue - Daemonise JobQueue plugin
version 2.13
use Daemonise; my $d = Daemonise->new(); $d->debug(1); $d->foreground(1) if $d->debug; $d->config_file('/path/to/some.conf'); $d->load_plugin('JobQueue'); $d->configure; # fetch job from "jobqueue_db" and put it in $d->job my $job_id = '585675aab87f878c9e98779e9e9c9ccadff'; my $job = $d->get_job($job_id); # creates a new job in "jobqueue_db" $job = $d->create_job({ some => { structured => 'hash' } }); # starts new job by sending a new job message to workflow worker $d->start_job('workflow_name', { user => "kevin", command => "play" }); # searches for job in couchdb using view 'find/by_something' and key provided $job = $d->find_job('by_bottles', "bottle_id"); # if you REALLY have to persist something in jobqueue right now, rather don't $d->update_job($d->job->{message} || $job->{message}); # mark job as done and persist $d->job_done($d->job->{message}); # stops workflow here if it is a job (if it has a message->meta->job_id) $d->stop_here; # recalculate totals $d->recalculate; # remove items from a job $d->remove_items($d->job->{message}->{data}->{options}, qw(item1 item2 item3));
log additional meta info of a job if present. this adds job (from <meta-id>>, session, user, account from the meta hash in front of each log message for easy tracking in any kind of log analyzer later.
job
<meta-
session
user
account
meta
unlock job before we get terminated
pass on some meta information if needed (user, account, session). unlock job ID before sending it off unless it's already unlocked or locking failed.
store rabbitMQ message in job attribute after receiving. try to lock job ID if applicable
empty job attribute before acknowledging a rabbitMQ message
method wrapper around _hooks attribute to accept hashes instead of a hash reference for convenience.
this method exists to collect all common tasks needed to finish up a message
1. log error if exists 2. log wait_for key if job stops here 3. log worker & update job unless locking failed (job only) 4. unlock job (job only) 5. reply to calling worker/rabbit if needed 6. acknowledge AMQP message
if message is a job, (un)lock rabbit on it using "activejob:job_id" as key and "some.rabbit.name:PID" as lock value.
if locking fails, throws error and returns undef, otherwise returns true.
call lock_job in 'unlock' mode and set boolean attribute
disable worker logging in msg->meta->log array
Find the index of a particular item name in the $data-{items_key}> array.
$data-
Return undef if not found.
Given a list of item names to remove, remove them from $data-{$self->items_key}> array and save them in $data-{'removed_' . $self->items_key}> array.
If item isn't found, it is silently ignored.
Return value is an array of removed item hashes.
Lenz Gschwendtner <norbu09@cpan.org>
This software is copyright (c) 2013 by Lenz Gschwendtner.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Daemonise, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Daemonise
CPAN shell
perl -MCPAN -e shell install Daemonise
For more information on module installation, please visit the detailed CPAN module installation guide.