NAME
Job::Machine::DB
VERSION
version 0.26
NAME
Job::Machine::DB - Database class for Job::Machine
METHODS
new
my $client = Job::Machine::DB->new(
dbh => $dbh,
queue => 'queue.subqueue',
);
my $client = Job::Machine::Base->new(
dsn => @dsn,
);
serializer
Returns the serializer, default Data::Serializer
listen
Sets up the listener. Quit listening to the named queues. If 'reply' is passed, we listen to the related reply queue instead of the task queue.
Return undef immediately if no queue is provided.
$self->listen( queue => 'queue_name' );
$self->listen( queue => \@queues, reply => 1 );
unlisten
Quit listening to the named queues. If 'reply' is passed, we unlisten to the related reply queue instead of the task queue.
Return undef immediately if no queue is provided.
$self->unlisten( queue => 'queue_name' );
$self->unlisten( queue => \@queues, reply => 1 );
notify
Sends an asynchronous notification to the named queue, with an optional payload. If 'reply' is true, then the queue names are taken to be reply.
Return undef immediately if no queue name is provided.
$self->notify( queue => 'queue_name' );
$self->notify( queue => 'queue_name', reply => 1, payload => $data );
get_notification
Retrieve one notification, if there is one
Retrievies the pending notifications.
my $notifies = $self->get_notification();
The return value is an arrayref where each row looks like this:
my ($name, $pid, $payload) = @$notify;
set_listen
Wait for a notification. The required parameter timeout tells for how long time to wait.
fetch_work_task
Fetch one work task from the task table
insert_task
Insert a row in the task table
set_task_status
Update the task with a new status
fetch_class
Fetch a class
fetch_task
Fetch a task
insert_class
Insert a row in the class table
insert_result
Insert a row in the result table
Argument
data - either a scalar value that will be inserted as the result, or a hashref containing the type and result
fetch_result
Fetch a result using the result id
fetch_first_result
Fetch a result using the task id
fetch_results
Fetch all results of a given task
get_statuses
Fetch all distinct statuses
get_classes
Fetch all classes
get_tasks
Fetch all tasks, joined with the class for a suitable name
revive_tasks
1. Find started tasks that have passed the time limit, most probably because of a dead worker. (status 100, modified < now - max_runtime)
2. Trim status so task can be tried again
fail_tasks
1. Find tasks that have failed too many times (# of result rows > $self->retries
2. fail them (Set status 900)
There's a hard limit (100) for how many tasks can be failed at one time for
performance resons
remove_tasks
3. Find tasks that should be removed (remove_task < now)
- delete them
- log
select_first
Select the first row from the given sql statement
select_all
Select all rows from the given sql statement
where_clause
Very light weight where clause builder
order_by
Very light weight order-by builder
AUTHOR
Kaare Rasmussen <kaare@cpan.org>.
COPYRIGHT
Copyright (C) 2009,2015, Kaare Rasmussen
This module is free software; you can redistribute it or modify it under the same terms as Perl itself.
AUTHOR
Kaare Rasmussen <kaare at cpan dot net>
COPYRIGHT AND LICENSE
This software is copyright (c) 2015 by Kaare Rasmussen.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.