Exemplo n.º 1
0
/*
Update the list of remote hosts with the specified hostname.
*/
func (otter *Otter) UpdateHost(hostname, previous string) (string, error) {
	options := etcd.SetOptions{
		TTL: 60 * time.Second,
	}
	now := time.Now().String()
	if previous != "" {
		options.PrevValue = previous
	}
	_, err := otter.etcdKeysApi.Set(context.Background(), fmt.Sprintf("/ping/%s", hostname), now, &options)
	if err != nil {
		return now, err
	}
	return now, nil
}