| @@ -180,12 +180,23 @@ func (c *consulRegistry) Register(s *Service, opts ...RegisterOption) error { | |||||||
|  |  | ||||||
| 	// if it's already registered and matches then just pass the check | 	// if it's already registered and matches then just pass the check | ||||||
| 	if ok && v == h { | 	if ok && v == h { | ||||||
|  | 		if options.TTL == time.Duration(0) { | ||||||
|  | 			services,_, err := c.Client.Health().Checks(s.Name, nil) | ||||||
|  | 			if err == nil { | ||||||
|  | 				for _, v := range services { | ||||||
|  | 					if v.ServiceID == node.Id { | ||||||
|  | 						return nil | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		}else{ | ||||||
| 			// if the err is nil we're all good, bail out | 			// if the err is nil we're all good, bail out | ||||||
| 			// if not, we don't know what the state is, so full re-register | 			// if not, we don't know what the state is, so full re-register | ||||||
| 			if err := c.Client.Agent().PassTTL("service:"+node.Id, ""); err == nil { | 			if err := c.Client.Agent().PassTTL("service:"+node.Id, ""); err == nil { | ||||||
| 				return nil | 				return nil | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	// encode the tags | 	// encode the tags | ||||||
| 	tags := encodeMetadata(node.Metadata) | 	tags := encodeMetadata(node.Metadata) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user