Example #1
0
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)
	}
}
Example #2
0
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)
	}
}
Example #3
0
func servicePassing(name string, agent *consul.Agent) {
	agent.PassTTL("service:"+name, "Service up and ready!")
}