mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 06:42:42 +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 {
|
||||
private $uri;
|
||||
|
||||
public function __construct($uri) {
|
||||
$this->uri = $uri;
|
||||
}
|
||||
|
||||
public function reindexAbstractDocument(
|
||||
PhabricatorSearchAbstractDocument $doc) {
|
||||
|
@ -183,8 +188,7 @@ final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine {
|
|||
}
|
||||
|
||||
private function executeRequest($path, array $data, $is_write = false) {
|
||||
$uri = PhabricatorEnv::getEnvConfig('search.elastic.host');
|
||||
$uri = new PhutilURI($uri);
|
||||
$uri = new PhutilURI($this->uri);
|
||||
$data = json_encode($data);
|
||||
|
||||
$uri->setPath($path);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -23,8 +23,9 @@ final class PhabricatorDefaultSearchEngineSelector
|
|||
extends PhabricatorSearchEngineSelector {
|
||||
|
||||
public function newEngine() {
|
||||
if (PhabricatorEnv::getEnvConfig('search.elastic.host')) {
|
||||
return new PhabricatorSearchEngineElastic();
|
||||
$elastic_host = PhabricatorEnv::getEnvConfig('search.elastic.host');
|
||||
if ($elastic_host) {
|
||||
return new PhabricatorSearchEngineElastic($elastic_host);
|
||||
}
|
||||
return new PhabricatorSearchEngineMySQL();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue