Remove product literal strings in "pht()", part 18
[phabricator.git] / src / infrastructure / cluster / search / PhabricatorSearchHost.php
blob93c3c4d93825fbeb35fb8c87bb98b7b569ff3336
1 <?php
3 abstract class PhabricatorSearchHost
4 extends Phobject {
6 const KEY_REFS = 'cluster.search.refs';
7 const KEY_HEALTH = 'cluster.search.health';
9 protected $engine;
10 protected $healthRecord;
11 protected $roles = array();
13 protected $disabled;
14 protected $host;
15 protected $port;
17 const STATUS_OKAY = 'okay';
18 const STATUS_FAIL = 'fail';
20 public function __construct(PhabricatorFulltextStorageEngine $engine) {
21 $this->engine = $engine;
24 public function setDisabled($disabled) {
25 $this->disabled = $disabled;
26 return $this;
29 public function getDisabled() {
30 return $this->disabled;
33 /**
34 * @return PhabricatorFulltextStorageEngine
36 public function getEngine() {
37 return $this->engine;
40 public function isWritable() {
41 return $this->hasRole('write');
44 public function isReadable() {
45 return $this->hasRole('read');
48 public function hasRole($role) {
49 return isset($this->roles[$role]) && $this->roles[$role] === true;
52 public function setRoles(array $roles) {
53 foreach ($roles as $role => $val) {
54 $this->roles[$role] = $val;
56 return $this;
59 public function getRoles() {
60 $roles = array();
61 foreach ($this->roles as $key => $val) {
62 if ($val) {
63 $roles[$key] = $val;
66 return $roles;
69 public function setPort($value) {
70 $this->port = $value;
71 return $this;
74 public function getPort() {
75 return $this->port;
78 public function setHost($value) {
79 $this->host = $value;
80 return $this;
83 public function getHost() {
84 return $this->host;
88 public function getHealthRecordCacheKey() {
89 $host = $this->getHost();
90 $port = $this->getPort();
91 $key = self::KEY_HEALTH;
93 return "{$key}({$host}, {$port})";
96 /**
97 * @return PhabricatorClusterServiceHealthRecord
99 public function getHealthRecord() {
100 if (!$this->healthRecord) {
101 $this->healthRecord = new PhabricatorClusterServiceHealthRecord(
102 $this->getHealthRecordCacheKey());
104 return $this->healthRecord;
107 public function didHealthCheck($reachable) {
108 $record = $this->getHealthRecord();
109 $should_check = $record->getShouldCheck();
111 if ($should_check) {
112 $record->didHealthCheck($reachable);
117 * @return string[] Get a list of fields to show in the status overview UI
119 abstract public function getStatusViewColumns();
121 abstract public function getConnectionStatus();