Esempio n. 1
0
func (k *K8s) GetNodeEnpoints(serviceName string) (string, error) {

	resp, err := k.etcdKeysApi.Get(context.Background(), "/registry/services/endpoints/default/"+serviceName, nil)
	if err != nil {
		return "", err
	}

	return resp.Node.Value, nil
}
Esempio n. 2
0
func (c *httpClusterClient) getLeaderEndpoint() (string, error) {
	mAPI := NewMembersAPI(c)
	leader, err := mAPI.Leader(context.Background())
	if err != nil {
		return "", err
	}

	return leader.ClientURLs[0], nil // TODO: how to handle multiple client URLs?
}
Esempio n. 3
0
func (k *K8s) WatcherEndpoints(serviceName string) (string, error) {

	watcher := k.etcdKeysApi.Watcher("/registry/services/endpoints/default/"+serviceName, &client.WatcherOptions{})

	resp, err := watcher.Next(context.Background())
	if err != nil {
		return "", err
	}

	return resp.Node.Value, nil
}