++ed by:
KHS

1 PAUSE user

김현승
and 1 contributors

NAME

IPC::AnyEvent::Gearman - IPC through gearmand.

VERSION

version 0.8

SYNOPSIS

    use AnyEvent;
    use IPC::AnyEvent::Gearman;
    
    #receive    
    my $recv = IPC::AnyEvent::Gearman->new(job_servers=>['localhost:9999']);
    $recv->channel('BE_CALLED'); # channel is set with a random UUID by default 
    $recv->on_recv(sub{
        my $msg = shift;
        print "received msg : $data\n";
        return "OK";#result
    });
    $recv->listen();

    my $cv = AE::cv;
    $cv->recv;

    #send
    my $ch = 'BE_CALLED';
    my $send = IPC::AnyEvent::Gearman->new(server=>['localhost:9999']);
    my $result = $send->send($ch,"TEST DATA");
    pritn $result; # prints "OK"

ATTRIBUTES

job_servers

ArrayRef of hosts. *REQUIRED*

channel

get/set channel. When set, reconnect to new channel. It is set with Random-UUID by default.

on_recv

on_recv Hander. First argument is DATA which is sent. This can be invoked after listen().

on_sent

on_sent handler. First argument is a channel string.

on_fail

on_fail handler. First argument is a channel string.

METHODS

listen

To receive message, you MUST call listen().

    my $sender = IPC::AnyEvent::Gearman->new(channel=>'ADMIN',job_servers=>['localhost:9998']);
    $sender->listen();

send

To send data to process listening channel, use this.

    my $sender = IPC::AnyEvent::Gearman->new(job_servers=>['localhost:9998']);
    $sender->send($channel,'DATA');

AUTHOR

KHS, HyeonSeung Kim <sng2nara@hanmail.net>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by HyeonSeung Kim.

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