jcalderonzumba/consul-discovery

Consul service discovery made easy

v1.0.0 2016-04-28 08:13 UTC

This package is not auto-updated.

Last update: 2024-12-21 20:41:31 UTC


README

Lightweight CONSUL service discovery for PHP

Requirements

You need to have CONSUL agent up and running.

Installation

This library can be installed with composer:

composer require jcalderonzumba/consul-discovery

Usage

The usage depends on the feature of CONSUL you want to use, for the moment we support:

  • Service discovery

Service discovery

Discovery of a service was never easier just use:

use Zumba\Consul\Features\Discovery;

$discovery = new Discovery([
  "consul_url" => "YOUR_CONSUL_HTTP_API"
]);

$service = $discovery->getService("pigeon");
echo $service->getID();
echo $service->getAddress();
echo $service->getPort();

By default we search ONLY for healthy service nearest to the agent. If you want this behavior to change open a issue and let's talk about it.

TODO

  • TEST, TEST, TEST!!!
  • Add more features to the SDK.