Esempio n. 1
0
func (v *Vulcand) Stop(s *service.Service) error {
	key := ServerPath(s)
	_, err := v.KeysAPI.Delete(context.Background(), key, nil)
	if err != nil {
		return etcd.ProcessEtcdErrors(err)
	}
	return nil
}
Esempio n. 2
0
func (v *Vulcand) setServer(s *service.Service) error {
	key := ServerPath(s)
	serv := Server{Url(s)}
	so := client.SetOptions{TTL: time.Duration(TTL) * time.Second}
	js, err := json.Marshal(serv)
	if err != nil {
		return err
	}
	_, err = v.KeysAPI.Set(context.Background(), key, string(js), &so)
	if err != nil {
		return etcd.ProcessEtcdErrors(err)
	}
	return nil
}
Esempio n. 3
0
func (v *Vulcand) Start(s *service.Service) error {
	key := BackendPath(s)
	b := Backend{s.Protocol}
	js, err := json.Marshal(b)
	if err != nil {
		return err
	}
	_, err = v.KeysAPI.Set(context.Background(), key, string(js), nil)
	if err != nil {
		return etcd.ProcessEtcdErrors(err)
	}
	err = v.setServer(s)
	if err != nil {
		return err
	}
	go v.heartBeat(s)
	return nil
}