The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

GearmanX::Simple::Worker - simple Gearman worker interface

WARNING - UNMAINTAINED

This code is no longer maintained.

Use at your own risk.

SYNOPSIS

use GearmanX::Simple::Worker;

sub do_something{
    my ( $job ) = @_;

    #do something here when called
}

my $worker = GearmanX::Simple::Worker->new( ["127.0.0.1:4730"], {
    'do_something' => \&do_something,
} );

sub do_something_else{
    my ( $job ) = @_;

    #does something else
}

$worker->register( "do_something_else", \&do_something_else );

$worker->work;

is the same as

use App::Daemon;
use Gearman::Worker;

my $worker = Gearman::Worker->new;
$worker->job_servers( "127.0.0.1:4730" );

sub do_something{
    my ( $job ) = @_;

    #do something here when called
}

$worker->register_function( "do_something" => \&do_something );

sub do_something_else{
    my ( $job ) = @_;

    #does something else
}

$worker->register_function( "do_something_else" => \&do_something_else );

App::Daemon::daemonize();
$worker->work while 1;

DESCRIPTION

Simple interface to Gearman::Worker and App::Daemon - for quick and easy creation of gearman workers that daemonise automatically

METHODS

new

takes two arguments arrayref of gearman servers (optional) hashref of function_name => function_ref

GearmanX::Simple::Worker->new(
    \@gearman_servers,
    {
        $function_name => $function_ref
    }
);

register

so you can register functions after the creation of the $worker object

$worker->register( $function_name, $function_ref );

work

start work and daemonise, no more functions can be registered once this has been called

SUPPORT

Bugs should always be submitted via the CPAN bug tracker

For other issues, contact the maintainer

AUTHORS

n0body <n0body@thisaintnews.com>

SEE ALSO

http://thisaintnews.com, Gearman::Worker, App:Daemon

LICENSE

Copyright (C) 2011 by n0body http://thisaintnews.com/

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