1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-01 19:22:42 +01:00

[elasticsearch] Add timeout to API calls

Summary:
Default of 300 seconds is more than likely too much in most cases.
Provide the option to override.

Test Plan:
Blocked ElasticSearch with iptables
Set timeout to 5 seconds and make sure we error early

Reviewers: epriestley, vrana

Reviewed By: vrana

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D2678
This commit is contained in:
macvicar 2012-06-08 00:06:26 -07:00
parent 5c5351b5e3
commit 1d94d49c17

View file

@ -18,11 +18,21 @@
final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine { final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine {
private $uri; private $uri;
private $timeout;
public function __construct($uri) { public function __construct($uri) {
$this->uri = $uri; $this->uri = $uri;
} }
public function setTimeout($timeout) {
$this->timeout = $timeout;
return $this;
}
public function getTimeout() {
return $this->timeout;
}
public function reindexAbstractDocument( public function reindexAbstractDocument(
PhabricatorSearchAbstractDocument $doc) { PhabricatorSearchAbstractDocument $doc) {
@ -206,6 +216,10 @@ final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine {
$future->setMethod('GET'); $future->setMethod('GET');
} }
if ($this->getTimeout()) {
$future->setTimeout($this->getTimeout());
}
list($body) = $future->resolvex(); list($body) = $future->resolvex();
if ($is_write) { if ($is_write) {