support services without version

This commit is contained in:
Asim Aslam 2018-03-01 17:35:13 +00:00
parent e8b050ffd5
commit 982e6068cf
2 changed files with 10 additions and 9 deletions

View File

@ -211,18 +211,18 @@ func (c *consulRegistry) GetService(name string) ([]*Service, error) {
}
// version is now a tag
version, found := decodeVersion(s.Service.Tags)
version, _ := decodeVersion(s.Service.Tags)
// service ID is now the node id
id := s.Service.ID
// key is always the version
key := version
// address is service address
address := s.Service.Address
// if we can't get the version we bail
// use old the old ways
if !found {
continue
// use node address
if len(address) == 0 {
address = s.Node.Address
}
svc, ok := serviceMap[key]
@ -236,6 +236,7 @@ func (c *consulRegistry) GetService(name string) ([]*Service, error) {
}
var del bool
for _, check := range s.Checks {
// delete the node if the status is critical
if check.Status == "critical" {

View File

@ -60,7 +60,7 @@ func (cw *consulWatcher) serviceHandler(idx uint64, data interface{}) {
for _, e := range entries {
serviceName = e.Service.Service
// version is now a tag
version, found := decodeVersion(e.Service.Tags)
version, _ := decodeVersion(e.Service.Tags)
// service ID is now the node id
id := e.Service.ID
// key is always the version
@ -68,9 +68,9 @@ func (cw *consulWatcher) serviceHandler(idx uint64, data interface{}) {
// address is service address
address := e.Service.Address
// if we can't get the version we bail
if !found {
continue
// use node address
if len(address) == 0 {
address = e.Node.Address
}
svc, ok := serviceMap[key]