NAME

Clutch::Worker - distributed job system's worker class

SYNOPSIS

# worker
package Your::Worker;
use strict;
use warnings;
use Clutch::Worker;

register_function(
    'echo' => sub {
        my $args = shift;
        $$ .':'. $args; # return worker process response.
    }
);
1;

# worker start script by single process
#! perl
use strict;
use warnings;
use Your::Worker;
Your::Worker->new(
    {
        address => "$ip:$port",
    }
)->run(); # stop by TERM signal to this process

# worker start script by multi prefork process
#! perl
use strict;
use warnings;
use Your::Worker;
Your::Worker->new(
    {
        address            => "$ip:$port",
        max_workers        => $worker_num,
        max_reqs_per_child => $max_reqs_per_child,
    }
)->new();

EXPORT WORKER FUNCTION

register_function($function_name, $callback_coderef);

$function_name

worker process function name.

client process specific this functin name.

$callback_coderef

client process call the function, execute thid $callback_coderef.

$callback_coderef's first argument is a client request parameter.

cascade($function_name, $args);

call self worker function.

$function_name

worker process function name.

$args

worker argument.

USAGE

my $worker = Your::Worker->new(\%opts);

$opts{address}

worker process listen address.

$opts{timeout}

seconds until timeout (default: 10)

$opts{max_workers}

number of worker processes (default: 0)

if max_workers is 0, worker start single process mode.

if you specific max_workers Zero or more, do prefork worker process.

$opts{spawn_interval}

if set, worker processes will not be spawned more than once than every given seconds. Also, when SIGHUP is being received, no more than one worker processes will be collected every given seconds. This feature is useful for doing a "slow-restart". See http://blog.kazuhooku.com/2011/04/web-serverstarter-parallelprefork.html for more information. (dedault: none)

$opts{max_reqs_per_child}

max. number of requests to be handled before a worker process exits (default: 100)

1 POD Error

The following errors were encountered while parsing the POD:

Around line 277:

=over without closing =back