mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
Pass URI to Elastic engine from outside
Summary: We need to generate the URI dynamically. This code is also generally better. Test Plan: Created custom search selector passing the custom URI to engine. Reviewers: epriestley, edward Reviewed By: epriestley CC: aran, Koolvin Differential Revision: https://secure.phabricator.com/D2655
This commit is contained in:
parent
76d758c048
commit
06b0f0d8ab
2 changed files with 10 additions and 5 deletions
|
@ -17,6 +17,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine {
|
final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine {
|
||||||
|
private $uri;
|
||||||
|
|
||||||
|
public function __construct($uri) {
|
||||||
|
$this->uri = $uri;
|
||||||
|
}
|
||||||
|
|
||||||
public function reindexAbstractDocument(
|
public function reindexAbstractDocument(
|
||||||
PhabricatorSearchAbstractDocument $doc) {
|
PhabricatorSearchAbstractDocument $doc) {
|
||||||
|
@ -183,8 +188,7 @@ final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function executeRequest($path, array $data, $is_write = false) {
|
private function executeRequest($path, array $data, $is_write = false) {
|
||||||
$uri = PhabricatorEnv::getEnvConfig('search.elastic.host');
|
$uri = new PhutilURI($this->uri);
|
||||||
$uri = new PhutilURI($uri);
|
|
||||||
$data = json_encode($data);
|
$data = json_encode($data);
|
||||||
|
|
||||||
$uri->setPath($path);
|
$uri->setPath($path);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2011 Facebook, Inc.
|
* Copyright 2012 Facebook, Inc.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -23,8 +23,9 @@ final class PhabricatorDefaultSearchEngineSelector
|
||||||
extends PhabricatorSearchEngineSelector {
|
extends PhabricatorSearchEngineSelector {
|
||||||
|
|
||||||
public function newEngine() {
|
public function newEngine() {
|
||||||
if (PhabricatorEnv::getEnvConfig('search.elastic.host')) {
|
$elastic_host = PhabricatorEnv::getEnvConfig('search.elastic.host');
|
||||||
return new PhabricatorSearchEngineElastic();
|
if ($elastic_host) {
|
||||||
|
return new PhabricatorSearchEngineElastic($elastic_host);
|
||||||
}
|
}
|
||||||
return new PhabricatorSearchEngineMySQL();
|
return new PhabricatorSearchEngineMySQL();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue