NAME
Job::Async - IO::Async abstraction for dispatching tasks to workers and receiving results
DESCRIPTION
More API details are in the respective base classes:
Job::Async::Client - queues jobs for workers to process
Job::Async::Worker - handles the job processing part
Normally, clients and workers would be in separate processes, probably distributed across multiple servers.
worker
Attaches a Job::Async::Worker instance as a child of this manager object, and returns the new worker instance.
Takes two parameters:
$type
- used to select the worker class, e.g.memory
orredis
$cfg
- the configuration parameters to pass to the new worker, as a hashref
Example:
my $worker = $jobman->worker(
redis => { uri => 'redis://server', mode => 'reliable' }
);
$worker->start;
$worker->jobs->each(sub { $_->done($_->data('x') . $_->data('y')) });
$worker->trigger;
client
Attaches a Job::Async::Client instance as a child of this manager object, and returns the new client instance.
Takes two parameters:
$type
- used to select the worker class, e.g.memory
orredis
$cfg
- the configuration parameters to pass to the new worker, as a hashref
Example:
print "Job result was " . $jobman->client(
redis => { uri => 'redis://server', mode => 'reliable' }
)->submit(
x => 123,
y => 456
)->get;
SEE ALSO
The main feature missing from the other alternatives is job completion notification - seems that "fire and forget" is a popular model.
Gearman - venerable contender for background job handling, usually database-backed
TheScwhartz - reliable job queuing, database-backed again
Minion - integrates with Mojolicious, normally seems to be used with a PostgreSQL backend. Has some useful routing and admin features. Does have some support for notification - see Minion::Notifier for example - but at the time of writing this came with significant overhead.
Mojo::Redis::Processor - a curious hybrid of Mojo::Redis2 and RedisDB, using pub/sub and a race on
SETNX
calls to handle multiple instances possibly trying to queue the same job at once.
INHERITED METHODS
- IO::Async::Notifier
-
add_child, adopt_future, adopted_futures, can_event, children, configure, configure_unknown, debug_printf, get_loop, invoke_error, invoke_event, loop, make_event_cb, maybe_invoke_event, maybe_make_event_cb, new, notifier_name, parent, remove_child, remove_from_parent
AUTHOR
Tom Molesworth <TEAM@cpan.org>
LICENSE
Copyright Tom Molesworth 2015-2017. Licensed under the same terms as Perl itself.