Subject: | UserAgent timeout |
Thank you so much for Store::CouchDB. It works great!
Currently, there is no way (code-hacking aside) to set the
LWP::UserAgent->timeout() value.
Could you please add a config parameter that will, in _call, work like
this:
my $timeout = $self->timeout;
$ua->timeout($timeout);
Or, as an (untested) patch:
diff -uNr Store/CouchDB.pm Store.patched/CouchDB.pm
--- Store/CouchDB.pm 2012-02-20 21:21:06.000000000 -0600
+++ Store.patched/CouchDB.pm 2012-09-11 07:16:59.558633564 -0500
@@ -97,6 +97,10 @@
is => 'rw',
default => sub { 5000 });
+has 'timeout' => (
+ is => 'rw',
+ default => '30');
+
=head1 FUNCTIONS
=head2 new
@@ -666,6 +670,8 @@
if ($content);
my $ua = LWP::UserAgent->new();
+ my $timeout = $self->timeout;
+ $ua->timeout($ua);
$ua->default_header('Content-Type' => "application/json");
my $res = $ua->request($req);
This will allow it to timeout more quickly in the event of a failure
than the LWP::UserAgent default of 180s. (I'd call this a wishlist item
if the default wasn't currently 3 minutes...) Note that I'm proposing to
impose a more sane default of 30s, but obviously that's up to you.
Many thanks!
-jbn
(on IRC as jbnewman)