Skip to content

Commit

Permalink
Use vip http port by default when available and add test (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
donhardman authored Dec 6, 2023
1 parent e89c407 commit f62270c
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 57 deletions.
108 changes: 54 additions & 54 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions src/Lib/ManticoreConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ protected function parse(string $config): void {
$this->$property = $value;
}
}

$this->setupEndpoints($endpoints);
}

Expand All @@ -123,8 +122,11 @@ protected function parse(string $config): void {
* @return void
*/
protected function setupEndpoints(array $endpoints): void {
$vipOnly = array_filter($endpoints, fn ($v) => $v['proto'] === '_vip' || $v['proto'] === 'http_vip');
$httpOnly = array_filter($endpoints, fn ($v) => $v['proto'] === 'http');
if ($httpOnly) {
if ($vipOnly) {
$endpoint = $vipOnly[array_key_first($vipOnly)];
} elseif ($httpOnly) {
$endpoint = $httpOnly[array_key_first($httpOnly)];
} else {
$endpoint = $endpoints[0] ?? null;
Expand All @@ -134,7 +136,7 @@ protected function setupEndpoints(array $endpoints): void {
return;
}

['proto' => $this->proto, 'host' => $this->host, 'port' => $this->port] = $endpoint;
['host' => $this->host, 'port' => $this->port] = $endpoint;
}

/**
Expand Down
Loading

0 comments on commit f62270c

Please sign in to comment.