Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / infrastructure / cluster / search / PhabricatorElasticsearchHost.php
blob39e8009df2e4e87f854b5b3202adf03ee031d72d
1 <?php
3 final class PhabricatorElasticsearchHost
4 extends PhabricatorSearchHost {
6 private $version = 5;
7 private $path = 'phabricator/';
8 private $protocol = 'http';
10 const KEY_REFS = 'search.elastic.refs';
13 public function setConfig($config) {
14 $this->setRoles(idx($config, 'roles', $this->getRoles()))
15 ->setHost(idx($config, 'host', $this->host))
16 ->setPort(idx($config, 'port', $this->port))
17 ->setProtocol(idx($config, 'protocol', $this->protocol))
18 ->setPath(idx($config, 'path', $this->path))
19 ->setVersion(idx($config, 'version', $this->version));
20 return $this;
23 public function getDisplayName() {
24 return pht('Elasticsearch');
27 public function getStatusViewColumns() {
28 return array(
29 pht('Protocol') => $this->getProtocol(),
30 pht('Host') => $this->getHost(),
31 pht('Port') => $this->getPort(),
32 pht('Index Path') => $this->getPath(),
33 pht('Elastic Version') => $this->getVersion(),
34 pht('Roles') => implode(', ', array_keys($this->getRoles())),
38 public function setProtocol($protocol) {
39 $this->protocol = $protocol;
40 return $this;
43 public function getProtocol() {
44 return $this->protocol;
47 public function setPath($path) {
48 $this->path = $path;
49 return $this;
52 public function getPath() {
53 return $this->path;
56 public function setVersion($version) {
57 $this->version = $version;
58 return $this;
61 public function getVersion() {
62 return $this->version;
65 public function getURI($to_path = null) {
66 $uri = id(new PhutilURI('http://'.$this->getHost()))
67 ->setProtocol($this->getProtocol())
68 ->setPort($this->getPort())
69 ->setPath($this->getPath());
71 if ($to_path) {
72 $uri->appendPath($to_path);
74 return $uri;
77 public function getConnectionStatus() {
78 $status = $this->getEngine()->indexIsSane($this);
79 return $status ? parent::STATUS_OKAY : parent::STATUS_FAIL;