diff options
-rw-r--r-- | lib/Net/Riak.pm | 10 | ||||
-rw-r--r-- | lib/Net/Riak/Client.pm | 6 | ||||
-rw-r--r-- | lib/Net/Riak/Role/UserAgent.pm | 4 |
3 files changed, 18 insertions, 2 deletions
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<ua_timeout> + +timeout for L<LWP::UserAgent> 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; } ); |