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

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

	log.Printf("[TRACE] %s: GET %s", d, &url.URL{
		Path:     "/v1/kv/" + d.prefix,
		RawQuery: opts.String(),
	})

	list, qm, err := clients.Consul().KV().List(d.prefix, opts.ToConsulOpts())
	if err != nil {
		return nil, nil, errors.Wrap(err, d.String())
	}

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

	pairs := make([]*KeyPair, 0, len(list))
	for _, pair := range list {
		key := strings.TrimPrefix(pair.Key, d.prefix)
		key = strings.TrimLeft(key, "/")

		pairs = append(pairs, &KeyPair{
			Path:        pair.Key,
			Key:         key,
			Value:       string(pair.Value),
			CreateIndex: pair.CreateIndex,
			ModifyIndex: pair.ModifyIndex,
			LockIndex:   pair.LockIndex,
			Flags:       pair.Flags,
			Session:     pair.Session,
		})
	}

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

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

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

	log.Printf("[TRACE] %s: GET %s", d, &url.URL{
		Path:     "/v1/kv/" + d.prefix,
		RawQuery: opts.String(),
	})

	list, qm, err := clients.Consul().KV().List(d.prefix, opts.ToConsulOpts())
	if err != nil {
		return nil, nil, errors.Wrap(err, d.String())
	}

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

	pairs := make([]*KeyPair, 0, len(list))
	for _, pair := range list {
		key := strings.TrimPrefix(pair.Key, d.prefix)
		key = strings.TrimLeft(key, "/")

		pairs = append(pairs, &KeyPair{
			Path:        pair.Key,
			Key:         key,
			Value:       string(pair.Value),
			CreateIndex: pair.CreateIndex,
			ModifyIndex: pair.ModifyIndex,
			LockIndex:   pair.LockIndex,
			Flags:       pair.Flags,
			Session:     pair.Session,
		})
	}

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

	return pairs, rm, nil
}
func ( d * KVListQuery ) Fetch ( clients * ClientSet , opts * QueryOptions ) ( interface { } , * ResponseMetadata , error ) { select { case <- d . stopCh : return nil , nil , ErrStopped default : } opts = opts . Merge ( & QueryOptions { Datacenter : d . dc , } ) log . Printf ( " " , d , & url . URL { Path : " " + d . prefix , RawQuery : opts . String ( ) , } ) list , qm , err := clients . Consul ( ) . KV ( ) . List ( d . prefix , opts . ToConsulOpts ( ) ) if err != nil { return nil , nil , errors . Wrap ( err , d . String ( ) ) } log . Printf ( " " , d , len ( list ) ) pairs := make ( [ ] * KeyPair , 0 , len ( list ) ) for _ , pair := range list { key := strings . TrimPrefix ( pair . Key , d . prefix ) key = strings . TrimLeft ( key , " " ) pairs = append ( pairs , & KeyPair { Path : pair . Key , Key : key , Value : string ( pair . Value ) , CreateIndex : pair . CreateIndex , ModifyIndex : pair . ModifyIndex , LockIndex : pair . LockIndex , Flags : pair . Flags , Session : pair . Session , } ) } rm := & ResponseMetadata { LastIndex : qm . LastIndex , LastContact : qm . LastContact , } return pairs , rm , nil }
// Fetch queries the Consul API defined by the given client.
Fetch queries the Consul API defined by the given client .