示例#1
0
// the types are so close yet SO DIFFERENT
func updateConsulTags(agent *consulapi.Agent, svc *consulapi.AgentService) error {
	registration := new(consulapi.AgentServiceRegistration)
	registration.Name = svc.Service
	registration.ID = svc.ID
	registration.Tags = svc.Tags
	registration.Port = svc.Port
	registration.Address = svc.Address
	return agent.ServiceRegister(registration)
}
示例#2
0
func doConsulAddService(agent *consulapi.Agent, ConsulName string, address string) (*consulapi.AgentService, error) {
	registration := new(consulapi.AgentServiceRegistration)
	registration.Name = ConsulName
	registration.Port = 80
	registration.Address = address
	err := agent.ServiceRegister(registration)
	if err != nil {
		return nil, err
	}
	svcs, err := agent.Services()
	if err != nil {
		return nil, err
	}
	svc, found := svcs[registration.Name]
	if !found {
		return nil, errors.New("Could not find service " + registration.Name + " after registration!")
	}
	return svc, nil
}