From 7bc76383dec104ac3308f28228ebc3ed29f5f001 Mon Sep 17 00:00:00 2001 From: Robin Edwards Date: Tue, 9 Nov 2010 10:01:13 +0000 Subject: added useragent timeout parameter --- lib/Net/Riak.pm | 10 +++++++++- lib/Net/Riak/Client.pm | 6 ++++++ lib/Net/Riak/Role/UserAgent.pm | 4 +++- 3 files changed, 18 insertions(+), 2 deletions(-) (limited to 'lib/Net') diff --git a/lib/Net/Riak.pm b/lib/Net/Riak.pm index 124279f..7412adb 100644 --- a/lib/Net/Riak.pm +++ b/lib/Net/Riak.pm @@ -33,7 +33,11 @@ sub bucket { =head1 SYNOPSIS - my $client = Net::Riak->new(host => 'http://10.0.0.40:8098'); + my $client = Net::Riak->new( + host => 'http://10.0.0.40:8098', + ua_timeout => 900 + ); + my $bucket = $client->bucket('blog'); my $obj = $bucket->new_object('new_post', {title => 'foo', content => 'bar'}); $obj->store; @@ -104,6 +108,10 @@ client_id for this client =back +=item B + +timeout for L in seconds, defaults to 3. + =head1 METHODS =head2 bucket diff --git a/lib/Net/Riak/Client.pm b/lib/Net/Riak/Client.pm index dbe3c16..4d14338 100644 --- a/lib/Net/Riak/Client.pm +++ b/lib/Net/Riak/Client.pm @@ -38,6 +38,12 @@ has http_response => ( handles => ['is_success'] ); +has ua_timeout => ( + is => 'rw', + isa => 'Int', + default => 3 +); + with 'Net::Riak::Role::UserAgent'; with qw/ Net::Riak::Role::REST diff --git a/lib/Net/Riak/Role/UserAgent.pm b/lib/Net/Riak/Role/UserAgent.pm index 123a378..122bf0c 100644 --- a/lib/Net/Riak/Role/UserAgent.pm +++ b/lib/Net/Riak/Role/UserAgent.pm @@ -18,7 +18,9 @@ has useragent => ( $opts{MaxLineLength} = 65_536; @LWP::Protocol::http::EXTRA_SOCK_OPTS = %opts; - my $ua = LWP::UserAgent->new; + my $ua = LWP::UserAgent->new( + timeout => $self->ua_timeout + ); $ua; } ); -- cgit 1.4.1