AnyEvent-ConnPool
view release on metacpan or search on metacpan
t/02-logic.t view on Meta::CPAN
use strict;
use warnings;
use AnyEvent::ConnPool;
use Test::More;
my $global_counter = 1;
my $connpool = AnyEvent::ConnPool->new(
constructor => sub {
return {value => $global_counter++};
},
size => 10,
);
$connpool->init();
my $last_counter = -1;
for (1 .. 30) {
my $conn = $connpool->get();
if ($last_counter > -1) {
ok($conn->conn()->{value} ne $last_counter, 'Round robin test');
t/03-transact.t view on Meta::CPAN
use strict;
use warnings;
use Test::More;
use AnyEvent::ConnPool;
my $acc = 0;
my $global_counter = 0;
my $connpool = AnyEvent::ConnPool->new(
constructor => sub {
return {value => $global_counter++};
},
size => 5,
init => 1,
);
my $c1 = $connpool->get(1);
my $c2 = $connpool->get(0);
my $c3 = $connpool->get(4);
t/04-check.t view on Meta::CPAN
use strict;
use warnings;
use AnyEvent;
use AnyEvent::ConnPool;
use Data::Dumper;
use Test::More;
my $global_counter = 0;
my $cv = AnyEvent->condvar();
my $connpool = AnyEvent::ConnPool->new(
constructor => sub {
$cv->begin();
return {value => $global_counter++};
},
check => {
cb => sub {
my $conn = shift;
$cv->end();
},
interval => 1,
},
init => 1,
size => 3,
t/05-reconnect.t view on Meta::CPAN
use strict;
use warnings;
use Test::More tests => 1;
use AnyEvent::ConnPool;
my $global_counter = 0;
my $connpool = AnyEvent::ConnPool->new(
size => 5,
init => 1,
constructor => sub {
return {value => $global_counter++};
},
);
my $unit = $connpool->get();
my $value = $unit->conn()->{value};
$unit->reconnect();
ok ($unit->conn()->{value} > $value, "Reconnecting");
t/06-dispatcher.t view on Meta::CPAN
use strict;
use warnings;
use AnyEvent::ConnPool;
use Data::Dumper;
use Test::More tests => 7;
my $global_counter = 1;
my $connpool = AnyEvent::ConnPool->new(
constructor => sub {
return bless {value => $global_counter++}, 'Foo::Bar::Baz';
},
size => 3,
init => 1,
);
my $d = $connpool->dispatcher();
my $result = $d->foo("Test");
( run in 0.798 second using v1.01-cache-2.11-cpan-49f99fa48dc )