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

View File

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