func registerCheckTtl(name string, ttl int, agent *consul.Agent) { reg := &consul.AgentCheckRegistration{ Name: name, } reg.TTL = strconv.Itoa(ttl) + "s" if err := agent.CheckRegister(reg); err != nil { log.Error("Failed to register check: ", err) } }
func serviceRegister(name string, port int, ttl int, agent *consul.Agent) { reg := &consul.AgentServiceRegistration{ Name: name, Port: port, Check: &consul.AgentServiceCheck{ TTL: strconv.Itoa(ttl) + "s", }, } if err := agent.ServiceRegister(reg); err != nil { log.Error("err: ", err) } }
func servicePassing(name string, agent *consul.Agent) { agent.PassTTL("service:"+name, "Service up and ready!") }