func (d *CatalogNodesQuery) Fetch(clients *ClientSet, opts *QueryOptions) (interface{}, *ResponseMetadata, error) {
	select {
	case <-d.stopCh:
		return nil, nil, ErrStopped
	default:
	}

	opts = opts.Merge(&QueryOptions{
		Datacenter: d.dc,
		Near:       d.near,
	})

	log.Printf("[TRACE] %s: GET %s", d, &url.URL{
		Path:     "/v1/catalog/nodes",
		RawQuery: opts.String(),
	})
	n, qm, err := clients.Consul().Catalog().Nodes(opts.ToConsulOpts())
	if err != nil {
		return nil, nil, errors.Wrap(err, d.String())
	}

	log.Printf("[TRACE] %s: returned %d results", d, len(n))

	nodes := make([]*Node, 0, len(n))
	for _, node := range n {
		nodes = append(nodes, &Node{
			ID:              node.ID,
			Node:            node.Node,
			Address:         node.Address,
			Datacenter:      node.Datacenter,
			TaggedAddresses: node.TaggedAddresses,
			Meta:            node.Meta,
		})
	}

	// Sort unless the user explicitly asked for nearness
	if d.near == "" {
		sort.Stable(ByNode(nodes))
	}

	rm := &ResponseMetadata{
		LastIndex:   qm.LastIndex,
		LastContact: qm.LastContact,
	}

	return nodes, rm, nil
}
func (d *CatalogNodesQuery) Fetch(clients *ClientSet, opts *QueryOptions) (interface{}, *ResponseMetadata, error) {
	select {
	case <-d.stopCh:
		return nil, nil, ErrStopped
	default:
	}

	opts = opts.Merge(&QueryOptions{
		Datacenter: d.dc,
		Near:       d.near,
	})

	log.Printf("[TRACE] %s: GET %s", d, &url.URL{
		Path:     "/v1/catalog/nodes",
		RawQuery: opts.String(),
	})
	n, qm, err := clients.Consul().Catalog().Nodes(opts.ToConsulOpts())
	if err != nil {
		return nil, nil, errors.Wrap(err, d.String())
	}

	log.Printf("[TRACE] %s: returned %d results", d, len(n))

	nodes := make([]*Node, 0, len(n))
	for _, node := range n {
		nodes = append(nodes, &Node{
			ID:              node.ID,
			Node:            node.Node,
			Address:         node.Address,
			Datacenter:      node.Datacenter,
			TaggedAddresses: node.TaggedAddresses,
			Meta:            node.Meta,
		})
	}

	// Sort unless the user explicitly asked for nearness
	if d.near == "" {
		sort.Stable(ByNode(nodes))
	}

	rm := &ResponseMetadata{
		LastIndex:   qm.LastIndex,
		LastContact: qm.LastContact,
	}

	return nodes, rm, nil
}
func ( d * CatalogNodesQuery ) Fetch ( clients * ClientSet , opts * QueryOptions ) ( interface { } , * ResponseMetadata , error ) { select { case <- d . stopCh : return nil , nil , ErrStopped default : } opts = opts . Merge ( & QueryOptions { Datacenter : d . dc , Near : d . near , } ) log . Printf ( " " , d , & url . URL { Path : " " , RawQuery : opts . String ( ) , } ) n , qm , err := clients . Consul ( ) . Catalog ( ) . Nodes ( opts . ToConsulOpts ( ) ) if err != nil { return nil , nil , errors . Wrap ( err , d . String ( ) ) } log . Printf ( " " , d , len ( n ) ) nodes := make ( [ ] * Node , 0 , len ( n ) ) for _ , node := range n { nodes = append ( nodes , & Node { ID : node . ID , Node : node . Node , Address : node . Address , Datacenter : node . Datacenter , TaggedAddresses : node . TaggedAddresses , Meta : node . Meta , } ) } // Sort unless the user explicitly asked for nearness if d . near == " " { sort . Stable ( ByNode ( nodes ) ) } rm := & ResponseMetadata { LastIndex : qm . LastIndex , LastContact : qm . LastContact , } return nodes , rm , nil }
// Fetch queries the Consul API defined by the given client and returns a slice
// of Node objects
Fetch queries the Consul API defined by the given client and returns a slice of Node objects