RPC::ToWorker - invoke remote perl functions asynchronously on remote systems
use RPC::ToWorker; do_remote_job( prefix => '#output prefix', chdir => '/some/directory', host => 'some.host.name', data => $data_to_send, preload => [qw(List::Of Required::Modules )], desc => 'remote job description', eval => 'my ($data) = @_; code_to_run(); return(@values)', when_done => sub { my (@slave_return_values) = @_; }, all_done => \&callback_for_slave_process_is_finished, error_handler => \&callback_for_STDERR_output_from_slave, output_handler => \&callback_for_STDOUT_output_from_slave, ); IO::Event::loop;
RPC::ToWorker provides a way to invoke a perl function on a remote system. It starts the remote perl process, passes data to it, and runs arbitrary code. It does this all with asynchronous IO (using IO::Event) so that multiple processes can run at the same time.
The slave job on the remote system can also invoke functions in the master process using master_call in RPC::ToWorker::Callback.
master_call
Required. The remote hostname.
Required. Code to eval on the remote host. Return values will be passed to when_done code reference. One argument will arrive in @_: the data element from below.
when_done
@_
data
Code reference to invoke with the return values from the eval.
eval
Data reference to pass to the remote process. It will be marshalled with Storable. This reference will be passed to the eval code as is (arrays will not be expanded).
Directory to chdir() to before doing anything else.
chdir()
Text (short) description of the remote job for error messages.
String to prefix each line of output from the slave with. Defaults to host:.
host:
Modules to load on the remote system, a list.
Code to eval prior to the main eval. Must not return.
return
This is currently disabled Code reference to call when there is STDERR output from the slave process. The default handler prints the output to STDOUT prefixed with prefix. $ioe is an IO::Event object so you can loop over it like a normal file descriptor.
prefix
$ioe
Code reference to call when there is STDOUT output from the slave process. The default handler prints the output to STDOUT prefixed with prefix. $ioe is an IO::Event object so you can loop over it like a normal file descriptor.
Code reference to invoke if the slave process failes to run. It may be invoked multiple times for the same slave.
Code reference to invoke when the slave process is fully shut down.
A hash of data that can be made available to master_call() invocations.
master_call()
Can this job be re-attempted? Defaults to 1.
Copyright (C) 2007-2008 SearchMe, Inc. Copyright (C) 2011 Google, Inc. This package may be used and redistributed under the terms of either the Artistic 2.0 or LGPL 2.1 license.
To install Proc::Parallel, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Proc::Parallel
CPAN shell
perl -MCPAN -e shell install Proc::Parallel
For more information on module installation, please visit the detailed CPAN module installation guide.