NAME

Clutch::Client - distributed job system's client class

SYNOPSIS

# client script
use strict;
use warnings;
use Clutch::Client;
my $args = shift || die 'missing args';
my $client = Clutch::Client->new(
    servers => [ "$worker_ip:$worker_port" ],
);
my $res = $client->request('echo', $args);
print $res, "\n";

METHOD

my $client = Clutch::Client->new(%opts);

$opts{servers}

The value is a reference to an array of worker addresses.

The server address is in the form host:port for network TCP connections

Client will distribute basic RoundRobin.

$opts{timeout}

seconds until timeout (default: 10)

my $res = $client->request($function_name, $args);

$function_name

worker process function name.

$args

get over client argument for worker process.

$args must be single line data.

my $res = $client->request_background($function_name, $args);

$function_name

worker process function name.

$args

get over client argument for worker process.

$args must be single line data.

$res

When the worker accepts the background request and returns the "OK"

my $res = $client->request_multi(\@args);

$args->[$i]->{function}

worker process function name.

$args->[$i]->{args}

get over client argument for worker process.

$args must be single line data.

$res

worker response here. The result is order request.

my $res = $client->request_background_multi(\@args);

$args->[$i]->{function}

worker process function name.

$args->[$i]->{args}

get over client argument for worker process.

$args must be single line data.

$res

worker response here. The result is order request.