summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Net/Riak/Role/PBC.pm8
-rw-r--r--t/pbc.t28
2 files changed, 35 insertions, 1 deletions
diff --git a/lib/Net/Riak/Role/PBC.pm b/lib/Net/Riak/Role/PBC.pm
index 605f032..bc32e3b 100644
--- a/lib/Net/Riak/Role/PBC.pm
+++ b/lib/Net/Riak/Role/PBC.pm
@@ -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,
)
);
}
diff --git a/t/pbc.t b/t/pbc.t
new file mode 100644
index 0000000..326ec3b
--- /dev/null
+++ b/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;