GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
TheSchwartz::Worker(3) User Contributed Perl Documentation TheSchwartz::Worker(3)

TheSchwartz::Worker - superclass for defining task behavior

    package MyWorker;
    use base qw( TheSchwartz::Worker );

    sub work {
        my $class = shift;
        my TheSchwartz::Job $job = shift;

        print "Workin' hard or hardly workin'? Hyuk!!\n";

        $job->completed();
    }


    package main;
    
    my $client = TheSchwartz->new( databases => $DATABASE_INFO );
    $client->can_do('MyWorker');
    $client->work();

TheSchwartz::Worker objects are the salt of the reliable job queuing earth. The behavior required to perform posted jobs are defined in sub-classes of TheSchwartz::Worker. These sub-classes are named for the ability required of a "TheSchwartz" client to do the job, so that the clients can dispatch automatically to the appropriate worker routine.

Because jobs can be performed by any machine running code for capable worker classes, "TheSchwartz::Worker"s are generally stateless. All mutable state is stored in the "TheSchwartz::Job" objects. This means all "TheSchwartz::Worker" methods are class methods, and "TheSchwartz::Worker" classes are generally never instantiated.

Define and customize how a job is performed by overriding these methods in your subclass:

Performs the job that required ability $class. Override this method to define how to do the job you're defining.

Note that will need to call "$job->completed()" or "$job->failed()" as appropriate to indicate success or failure. See TheSchwartz::Job.

Returns the number of times workers should attempt the given job. After this many tries, the job is marked as completed with errors (that is, a "TheSchwartz::ExitStatus" is recorded for it) and removed from the queue. By default, returns 0.

Returns the number of seconds after a failure workers should wait until reattempting a job that has already failed $num_failures times. By default, returns 0.

Returns the number of seconds to allow a "TheSchwartz::ExitStatus" record for a job performed by this worker class to exist. By default, returns 0.

Returns the number of seconds workers of this class will claim a grabbed a job. That is, returns the length of the timeout after which other workers will decide a worker that claimed a job has crashed or faulted without marking the job failed. Jobs that are marked as failed by a worker are also marked for immediate retry after a delay indicated by "retry_delay()".

Finds and claims a job for workers with ability $class, using "TheSchwartz" client $client. This job can then be passed to "work()" or "work_safely()" to perform it.

Performs the job associated with the worker's class name. If an error is thrown while doing the job, the job is appropriately marked as failed, unlike when calling "work()" directly.
2022-04-08 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.