Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/drnic/consul-discovery
Go package is a service discovery client for Consul
https://github.com/drnic/consul-discovery
Last synced: 2 months ago
JSON representation
Go package is a service discovery client for Consul
- Host: GitHub
- URL: https://github.com/drnic/consul-discovery
- Owner: drnic
- Created: 2014-05-24T00:55:27.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2021-11-17T18:07:48.000Z (about 3 years ago)
- Last Synced: 2023-04-10T17:09:45.451Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 133 KB
- Stars: 25
- Watchers: 4
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
consul-discovery
================This Go package is a service discovery client for [Consul](http://www.consul.io).
Related: see [consul-kv](https://github.com/armon/consul-kv) for a key-value client package to Consul.
Documentation
-------------The full documentation is available on [Godoc](http://godoc.org/github.com/drnic/consul-discovery)
Usage
-----Below is an example of using the Consul Discovery client:
```go
client, _ := consuldiscovery.NewClient(consuldiscovery.DefaultConfig())
criticalChecks, _ := client.HealthByState("critical")services, _ := client.CatalogServices()
serviceNodes, _ := client.CatalogServiceByName(services[0].Name)
```Also see examples folder for runnable examples.
First, run the `consul agent` command:
```
consul agent -data-dir /tmp/consul -server -bootstrap -config-dir testconfig
```Now the examples can be run on this example local consul node:
```
$ go run examples/catalog.go
Services: consuldiscovery.CatalogServices{consuldiscovery.CatalogService{Name:"consul"...}consul: consuldiscovery.CatalogServiceByName{consuldiscovery.CatalogServiceNode{Node:"drnic.local"...}
simple_service: consuldiscovery.CatalogServiceByName{consuldiscovery.CatalogServiceNode{Node:"drnic.local"...}
```Development
-----------To run the tests, first run a consul server with API port 8500:
```
consul agent -data-dir /tmp/consul -server -bootstrap -config-dir testconfig
```The run tests:
```
go test
```