Permalink
Browse files

Merge pull request #18 from sukria/master

Support for timeout attribute in the PBC client
  • Loading branch information...
2 parents 1d26311 + 5a71e04 commit 7afabed9e14ec3ea9de72c39fec56672ec63c5c1 @robinedwards robinedwards committed Jul 4, 2012
Showing with 35 additions and 1 deletion.
  1. +7 −1 lib/Net/Riak/Role/PBC.pm
  2. +28 −0 t/pbc.t
View
@@ -37,6 +37,12 @@ has socket => (
predicate => 'has_socket',
);
+has timeout => (
+ is => 'ro',
+ isa => Int,
+ default => 30,
+);
+
sub is_alive {
my $self = shift;
return $self->send_message('PingReq');
@@ -56,7 +62,7 @@ sub connect {
PeerAddr => $self->host,
PeerPort => $self->port,
Proto => 'tcp',
- Timeout => 30,
+ Timeout => $self->timeout,
)
);
}
View
28 t/pbc.t
@@ -0,0 +1,28 @@
+use Net::Riak;
+use strict;
+use warnings;
+
+use Test::More;
+
+my $r = Net::Riak->new(
+ transport => 'PBC',
+ host => '10.0.0.40',
+ port => 8080
+ );
+
+is $r->client->timeout,30, "timeout defaults to 30";
+
+my $r = Net::Riak->new(
+ transport => 'PBC',
+ host => '10.0.0.40',
+ port => 8080,
+ timeout => 2,
+ );
+
+is $r->client->timeout, 2, "timeout changed";
+
+
+
+
+
+done_testing;

0 comments on commit 7afabed

Please sign in to comment.