AnyEvent-ZeroMQ
view release on metacpan or search on metacpan
t/basic-tcp.t view on Meta::CPAN
use strict;
use warnings;
use Test::More;
use AnyEvent::ZeroMQ;
use ZeroMQ::Raw;
use ZeroMQ::Raw::Constants qw(ZMQ_NOBLOCK ZMQ_PUB ZMQ_SUB ZMQ_SUBSCRIBE);
my $c = ZeroMQ::Raw::Context->new( threads => 10 );
my $pub = ZeroMQ::Raw::Socket->new($c, ZMQ_PUB);
my $sub = ZeroMQ::Raw::Socket->new($c, ZMQ_SUB);
$pub->bind('tcp://127.0.0.1:1234');
$sub->connect('tcp://127.0.0.1:1234');
$sub->setsockopt(ZMQ_SUBSCRIBE, '');
my $cv = AnyEvent->condvar;
$cv->begin; # wait for writability
$cv->begin; # wait for readability
t/handle-basic-tcp.t view on Meta::CPAN
use strict;
use warnings;
use Test::More;
use EV;
use AnyEvent::ZeroMQ::Handle;
use ZeroMQ::Raw;
use ZeroMQ::Raw::Constants qw(ZMQ_SUBSCRIBE ZMQ_PUB ZMQ_SUB ZMQ_NOBLOCK ZMQ_IDENTITY);
my $c = ZeroMQ::Raw::Context->new( threads => 1 );
my $pub = ZeroMQ::Raw::Socket->new($c, ZMQ_PUB);
my $sub = ZeroMQ::Raw::Socket->new($c, ZMQ_SUB);
my $pub_h = AnyEvent::ZeroMQ::Handle->new( socket => $pub, identity => 'pub_h' );
my $sub_h = AnyEvent::ZeroMQ::Handle->new( socket => $sub );
ok $pub_h, 'got publish handle';
ok $sub_h, 'got subscribe handle';
is $pub_h->identity, 'pub_h', 'got cached id';
t/publish-subscribe-multiconnect.t view on Meta::CPAN
use warnings;
use Test::More;
use ok 'AnyEvent::ZeroMQ::Role::WithHandle';
use ok 'AnyEvent::ZeroMQ::Publish';
use ok 'AnyEvent::ZeroMQ::Subscribe';
my $ENDPOINT1 = 'inproc://#1';
my $ENDPOINT2 = 'inproc://#2';
my $c = ZeroMQ::Raw::Context->new( threads => 0 );
my $sub = AnyEvent::ZeroMQ::Subscribe->new(
context => $c,
bind => $ENDPOINT1,
);
my $pub = AnyEvent::ZeroMQ::Publish->new(
context => $c,
connect => $ENDPOINT1,
);
t/publish-subscribe-topics.t view on Meta::CPAN
use strict;
use warnings;
use Test::More;
use AnyEvent::ZeroMQ::Publish;
use AnyEvent::ZeroMQ::Subscribe;
my $ENDPOINT = 'inproc://#1';
my $c = ZeroMQ::Raw::Context->new( threads => 0 );
my $pub = AnyEvent::ZeroMQ::Publish->with_traits('Topics')->new(
context => $c,
bind => $ENDPOINT,
);
my $sub = AnyEvent::ZeroMQ::Subscribe->with_traits('Topics')->new(
context => $c,
connect => $ENDPOINT,
topics => [qw/foo: bar:/],
t/publish-subscribe.t view on Meta::CPAN
use strict;
use warnings;
use Test::More;
use ok 'AnyEvent::ZeroMQ::Role::WithHandle';
use ok 'AnyEvent::ZeroMQ::Publish';
use ok 'AnyEvent::ZeroMQ::Subscribe';
my $ENDPOINT = 'inproc://#1';
my $c = ZeroMQ::Raw::Context->new( threads => 0 );
my $pub = AnyEvent::ZeroMQ::Publish->new(
context => $c,
bind => $ENDPOINT,
);
my $all = AnyEvent::ZeroMQ::Subscribe->new(
context => $c,
connect => $ENDPOINT,
);
t/push-pull-multi.t view on Meta::CPAN
use Test::More;
use ZeroMQ::Raw::Context;
use ok 'AnyEvent::ZeroMQ::Push';
use ok 'AnyEvent::ZeroMQ::Pull';
my $ENDPOINT_A = 'inproc://#A';
my $ENDPOINT_B = 'inproc://#B';
my $ENDPOINT_C = 'inproc://#C';
my $c = ZeroMQ::Raw::Context->new( threads => 0 );
# __PULL____ __PULL____
# / \ / \
# | worker a | | worker b |
# \__________/ [B]<-\ \__________/ [C]
# \ \ / ^
# \ \ / /
# \ \ / /
# \ \ / |
# \->[A]<-----X /
t/push-pull.t view on Meta::CPAN
use strict;
use warnings;
use Test::More;
use ok 'AnyEvent::ZeroMQ::Push';
use ok 'AnyEvent::ZeroMQ::Pull';
my $ENDPOINT = 'inproc://#1';
my @c = (context => ZeroMQ::Raw::Context->new( threads => 0 ));
my $server = AnyEvent::ZeroMQ::Push->new( @c, bind => $ENDPOINT );
my $client_a = AnyEvent::ZeroMQ::Pull->new( @c, connect => $ENDPOINT );
my $cv = AnyEvent->condvar;
my @to_write = qw/a b/;
my ($a, $b, $drain) = (0, 0, 0);
$cv->begin for 1..8;
$client_a->on_read(sub { $a++; $cv->end });
t/request-reply.t view on Meta::CPAN
use Test::More;
use ok 'AnyEvent::ZeroMQ::Role::WithHandle';
use ok 'AnyEvent::ZeroMQ::Request';
use ok 'AnyEvent::ZeroMQ::Reply';
my $on_request;
my $_on_request = sub { eval { $on_request->() } };
my $ENDPOINT = 'inproc://#1';
my $c = ZeroMQ::Raw::Context->new( threads => 0 );
my $req = AnyEvent::ZeroMQ::Request->new(
context => $c,
bind => $ENDPOINT,
);
my $rep = AnyEvent::ZeroMQ::Reply->new(
context => $c,
connect => $ENDPOINT,
on_request => sub {
( run in 0.470 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )