GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  GEARMAN::XS::WORKER (3)

.ds Aq ’

NAME

Gearman::XS::Worker - Perl worker for gearman using libgearman

CONTENTS

SYNOPSIS



  use Gearman::XS qw(:constants);
  use Gearman::XS::Worker;

  $worker = new Gearman::XS::Worker;

  $ret = $worker->add_server($host, $port);
  if ($ret != GEARMAN_SUCCESS)
  {
    printf(STDERR "%s\n", $worker->error());
    exit(1);
  }

  $ret = $worker->add_function("reverse", 0, \&reverse, $options);
  if ($ret != GEARMAN_SUCCESS)
  {
    printf(STDERR "%s\n", $worker->error());
  }

  while (1)
  {
    my $ret = $worker->work();
    if ($ret != GEARMAN_SUCCESS)
    {
      printf(STDERR "%s\n", $worker->error());
    }
  }

  sub reverse {
    $job = shift;

    $workload = $job->workload();
    $result   = reverse($workload);

    printf("Job=%s Function_Name=%s Workload=%s Result=%s\n",
            $job->handle(), $job->function_name(), $job->workload(), $result);

    return $result;
  }



DESCRIPTION

Gearman::XS::Worker is a worker class for the Gearman distributed job system using libgearman.

CONSTRUCTOR

Gearman::XS::Worker->new()

Returns a Gearman::XS::Worker object.

METHODS

CW$worker->add_server($host, CW$port)

Add a job server to a worker. This goes into a list of servers than can be used to run tasks. No socket I/O happens here, it is just added to a list. Returns a standard gearman return value.

CW$worker->add_servers($servers)

Add a list of job servers to a worker. The format for the server list is: SERVER[:PORT][,SERVER[:PORT]]... No socket I/O happens here, it is just added to a list. Returns a standard gearman return value.

CW$worker->echo($data)

Send data to all job servers to see if they echo it back. This is a test function to see if job servers are responding properly. Returns a standard gearman return value.

CW$worker->add_function($function_name, CW$timeout, CW$function, CW$function_args)

Register and add callback function for worker. Returns a standard gearman return value.

CW$worker->work()

Wait for a job and call the appropriate callback function when it gets one. Returns a standard gearman return value.

CW$worker->grab_job()

Get a job from one of the job servers. Returns a standard gearman return value.

CW$worker->error()

Return an error string for the last error encountered.

CW$worker->options()

Get options for a worker.

CW$worker->set_options($options)

Set options for a worker.

CW$worker->add_options($options)

Add options for a worker.

CW$worker->remove_options($options)

Remove options for a worker.

CW$worker->timeout()

Get current socket I/O activity timeout value. Returns Timeout in milliseconds to wait for I/O activity.

CW$worker->set_timeout($timeout)

Set socket I/O activity timeout for connections in milliseconds.

CW$worker->register($function_name, CW$timeout)

Register function with job servers with an optional timeout. The timeout specifies how many seconds the server will wait before marking a job as failed. Returns a standard gearman return value.

CW$worker->unregister($function_name)

Unregister function with job servers. Returns a standard gearman return value.

CW$worker->unregister_all()

Unregister all functions with job servers. Returns a standard gearman return value.

CW$worker->function_exist($function_name)

See if a function exists in the server. Returns 1 if the function exists, empty string if not.

CW$worker->wait()

When in non-blocking I/O mode, wait for activity from one of the servers.

CW$worker->set_log_fn($function, CW$verbose)

Set logging function.

BUGS

Any in libgearman plus many others of my own.

COPYRIGHT

Copyright (C) 2009-2010 Dennis Schoen

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.9 or, at your option, any later version of Perl 5 you may have available.

WARRANTY

This is free software. IT COMES WITHOUT WARRANTY OF ANY KIND.

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Dennis Schoen <dennis@blogma.de>
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 GEARMAN::XS::WORKER (3) 2011-07-18

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.