Jeremy Stashewsky > TheSchwartz-Moosified > TheSchwartz::Moosified



Annotate this POD


Open  3
View/Report Bugs
Module Version: 0.06   Source  


TheSchwartz::Moosified - TheSchwartz based on Moose!


    use TheSchwartz::Moosified;

    my $client = TheSchwartz::Moosified->new();
    # rest are the same as TheSchwartz
    # in some place we insert job into TheSchwartz::Moosified
    # in another place we run this job
    # 1, insert job in cgi/Catalyst
    use TheSchwartz::Moosified;
    my $client = TheSchwartz::Moosified->new();
    $client->insert('My::Worker::A', { args1 => 1, args2 => 2 } );
    # 2, defined the heavy things in My::Worker::A
    package My::Worker::A;
    use base 'TheSchwartz::Moosified::Worker';
    sub work {
        my ($class, $job) = @_;
        # $job is an instance of TheSchwartz::Moosified::Job
        my $args = $job->args;
        # do heavy things like resize photos, add 1 to 2 etc.
    # 3, run the worker in a non-stop script
    use TheSchwartz::Moosified;
    my $client = TheSchwartz::Moosified->new();


TheSchwartz is a powerful job queue. This module is a Moose implemention.

read more on TheSchwartz



The methods of TheSchwartz clients used by applications posting jobs to the queue are:

$client->insert( $job )

Adds the given TheSchwartz::Job to one of the client's job databases.

$client->insert( $funcname, $arg )

Adds a new job with funcname $funcname and arguments $arg to the queue.


The methods of TheSchwartz clients for use in worker processes are:

$client->can_do( $ability )

Adds $ability to the list of abilities $client is capable of performing. Subsequent calls to that client's work methods will find jobs requiring the given ability.


Find and perform one job $client can do.


Find and perform jobs $client can do until no more such jobs are found in any of the client's job databases.

$client->work( [$delay] )

Find and perform any jobs $client can do, forever. When no job is available, the working process will sleep for $delay seconds (or 5, if not specified) before looking again.

$client->find_job_for_workers( [$abilities] )

Returns a TheSchwartz::Job for a random job that the client can do. If specified, the job returned matches one of the abilities in the arrayref $abilities, rather than $client's abilities.

$client->find_job_with_coalescing_value( $ability, $coval )

Returns a TheSchwartz::Job for a random job for a worker capable of $ability and with a coalescing value of $coval.

$client->find_job_with_coalescing_prefix( $ability, $coval )

Returns a TheSchwartz::Job for a random job for a worker capable of $ability and with a coalescing value beginning with $coval.

Note the TheSchwartz implementation of this function uses a LIKE query to find matching jobs, with all the attendant performance implications for your job databases.


TheSchwartz, TheSchwartz::Simple


Fayland Lam, <fayland at>

Jeremy Stashewsky, <jstash+cpan at>


Copyright 2008 Fayland Lam, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: