[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:
@@ -18,11 +18,21 @@
|
||||
|
||||
final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine {
|
||||
private $uri;
|
||||
private $timeout;
|
||||
|
||||
public function __construct($uri) {
|
||||
$this->uri = $uri;
|
||||
}
|
||||
|
||||
public function setTimeout($timeout) {
|
||||
$this->timeout = $timeout;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTimeout() {
|
||||
return $this->timeout;
|
||||
}
|
||||
|
||||
public function reindexAbstractDocument(
|
||||
PhabricatorSearchAbstractDocument $doc) {
|
||||
|
||||
@@ -206,6 +216,10 @@ final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine {
|
||||
$future->setMethod('GET');
|
||||
}
|
||||
|
||||
if ($this->getTimeout()) {
|
||||
$future->setTimeout($this->getTimeout());
|
||||
}
|
||||
|
||||
list($body) = $future->resolvex();
|
||||
|
||||
if ($is_write) {
|
||||
|
||||
Reference in New Issue
Block a user