If TTL is nil it might bail
This commit is contained in:
		| @@ -179,19 +179,29 @@ func (c *consulRegistry) Register(s *Service, opts ...RegisterOption) error { | |||||||
| 	tags = append(tags, encodeEndpoints(s.Endpoints)...) | 	tags = append(tags, encodeEndpoints(s.Endpoints)...) | ||||||
| 	tags = append(tags, encodeVersion(s.Version)) | 	tags = append(tags, encodeVersion(s.Version)) | ||||||
|  |  | ||||||
|  | 	var check *consul.AgentServiceCheck | ||||||
|  |  | ||||||
|  | 	if options.TTL > time.Duration(0) { | ||||||
|  | 		check = &consul.AgentServiceCheck{ | ||||||
|  | 			TTL: fmt.Sprintf("%v", options.TTL), | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	if err := c.Client.Agent().ServiceRegister(&consul.AgentServiceRegistration{ | 	if err := c.Client.Agent().ServiceRegister(&consul.AgentServiceRegistration{ | ||||||
| 		ID:      node.Id, | 		ID:      node.Id, | ||||||
| 		Name:    s.Name, | 		Name:    s.Name, | ||||||
| 		Tags:    tags, | 		Tags:    tags, | ||||||
| 		Port:    node.Port, | 		Port:    node.Port, | ||||||
| 		Address: node.Address, | 		Address: node.Address, | ||||||
| 		Check: &consul.AgentServiceCheck{ | 		Check:   check, | ||||||
| 			TTL: fmt.Sprintf("%v", options.TTL), |  | ||||||
| 		}, |  | ||||||
| 	}); err != nil { | 	}); err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	if options.TTL == time.Duration(0) { | ||||||
|  | 		return nil | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	return c.Client.Agent().PassTTL("service:"+node.Id, "") | 	return c.Client.Agent().PassTTL("service:"+node.Id, "") | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user