Health.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. namespace Hyperf\Consul;
  12. class Health extends Client implements HealthInterface
  13. {
  14. public function node($node, array $options = []): ConsulResponse
  15. {
  16. $params = [
  17. 'query' => $this->resolveOptions($options, ['dc']),
  18. ];
  19. return $this->request('GET', '/v1/health/node/' . $node, $params);
  20. }
  21. public function checks($service, array $options = []): ConsulResponse
  22. {
  23. $params = [
  24. 'query' => $this->resolveOptions($options, ['dc']),
  25. ];
  26. return $this->request('GET', '/v1/health/checks/' . $service, $params);
  27. }
  28. public function service($service, array $options = []): ConsulResponse
  29. {
  30. $params = [
  31. 'query' => $this->resolveOptions($options, ['dc', 'tag', 'passing']),
  32. ];
  33. return $this->request('GET', '/v1/health/service/' . $service, $params);
  34. }
  35. public function state($state, array $options = []): ConsulResponse
  36. {
  37. $params = [
  38. 'query' => $this->resolveOptions($options, ['dc']),
  39. ];
  40. return $this->request('GET', '/v1/health/state/' . $state, $params);
  41. }
  42. }