The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Job::Async - IO::Async abstraction for dispatching tasks to workers and receiving results

DESCRIPTION

More API details are in the respective base classes:

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 or redis

  • $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 or redis

  • $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.

INHERITED METHODS

IO::Async::Notifier

add_child, adopt_future, 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.