Using the service id in check hash

This commit is contained in:
Diptanu Choudhury 2015-11-25 15:17:27 -08:00
parent b35819f10a
commit f66069a08d
2 changed files with 3 additions and 2 deletions

View File

@ -270,7 +270,7 @@ func (c *ConsulService) makeChecks(service *structs.Service, ip string, port int
check.Name = fmt.Sprintf("service: '%s' check", service.Name)
}
cr := &consul.AgentCheckRegistration{
ID: check.Hash(),
ID: check.Hash(service.Id),
Name: check.Name,
ServiceID: service.Id,
}

View File

@ -1040,8 +1040,9 @@ func (sc *ServiceCheck) Validate() error {
return nil
}
func (sc *ServiceCheck) Hash() string {
func (sc *ServiceCheck) Hash(serviceId string) string {
h := sha1.New()
io.WriteString(h, serviceId)
io.WriteString(h, sc.Name)
io.WriteString(h, sc.Type)
io.WriteString(h, sc.Script)