diff options
| author | Yuriy Andamasov <yuriy@andamasov.com> | 2026-05-23 17:49:28 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-23 17:49:28 +0300 |
| commit | 422681512d98175eb558271589cf433c1c9a1020 (patch) | |
| tree | 00ad5372e564a0c332f7dc26abe9836681f9361e /src/host | |
| parent | 49588447d6865c968143db7db1ab2b82b191e29e (diff) | |
| parent | 5a47a44b717a912bd22d7e03921521cfec49074e (diff) | |
| download | phorge-elasticsearch-modern-production.tar.gz phorge-elasticsearch-modern-production.zip | |
Merge pull request #16 from vyos/developmentHEADv0.1.0production
Release v0.1.0 — promote development to production
Diffstat (limited to 'src/host')
| -rw-r--r-- | src/host/VyOSElasticModernHost.php | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/src/host/VyOSElasticModernHost.php b/src/host/VyOSElasticModernHost.php new file mode 100644 index 0000000..ec86eb2 --- /dev/null +++ b/src/host/VyOSElasticModernHost.php @@ -0,0 +1,93 @@ +<?php + +/** + * Host subclass for the phorge-elasticsearch-modern extension. + * + * Mirrors PhabricatorElasticsearchHost's surface area; differs only in + * the display name and (in future versions) the auth config fields. + */ +final class VyOSElasticModernHost extends PhabricatorSearchHost { + + private $version = 7; + private $path = 'phabricator/'; + private $protocol = 'http'; + + const KEY_REFS = 'search.elasticmodern.refs'; + + public function setConfig($config) { + $this->setRoles(idx($config, 'roles', $this->getRoles())) + ->setHost(idx($config, 'host', $this->host)) + ->setPort(idx($config, 'port', $this->port)) + ->setProtocol(idx($config, 'protocol', $this->protocol)) + ->setPath(idx($config, 'path', $this->path)) + ->setVersion(idx($config, 'version', $this->version)); + return $this; + } + + public function getDisplayName() { + return pht('Elasticsearch (modern)'); + } + + public function getStatusViewColumns() { + return array( + pht('Protocol') => $this->getProtocol(), + pht('Host') => $this->getHost(), + pht('Port') => $this->getPort(), + pht('Index Path') => $this->getPath(), + pht('Version') => $this->getVersion(), + pht('Roles') => implode(', ', array_keys($this->getRoles())), + ); + } + + public function setProtocol($protocol) { + $this->protocol = $protocol; + return $this; + } + + public function getProtocol() { + return $this->protocol; + } + + public function setPath($path) { + $this->path = $path; + return $this; + } + + public function getPath() { + return $this->path; + } + + public function setVersion($version) { + $this->version = $version; + return $this; + } + + public function getVersion() { + return $this->version; + } + + /** + * @return PhutilURI + */ + public function getURI($to_path = null) { + $uri = id(new PhutilURI('http://'.$this->getHost())) + ->setProtocol($this->getProtocol()) + ->setPort($this->getPort()) + ->setPath($this->getPath()); + + if ($to_path) { + $uri->appendPath($to_path); + } + return $uri; + } + + public function getConnectionStatus() { + try { + $status = $this->getEngine()->indexIsSane($this); + return $status ? parent::STATUS_OKAY : parent::STATUS_FAIL; + } catch (Exception $e) { + return parent::STATUS_FAIL; + } + } + +} |
