// parseQueryMeta is used to help parse query meta-data
193238
func parseQueryMeta(resp *http.Response, q *QueryMeta) error {
	header := resp.Header

	// Parse the X-Nomad-Index
	index, err := strconv.ParseUint(header.Get("X-Nomad-Index"), 10, 64)
	if err != nil {
		return fmt.Errorf("Failed to parse X-Nomad-Index: %v", err)
	}
	q.LastIndex = index

	// Parse the X-Nomad-LastContact
	last, err := strconv.ParseUint(header.Get("X-Nomad-LastContact"), 10, 64)
	if err != nil {
		return fmt.Errorf("Failed to parse X-Nomad-LastContact: %v", err)
	}
	q.LastContact = time.Duration(last) * time.Millisecond

	// Parse the X-Nomad-KnownLeader
	switch header.Get("X-Nomad-KnownLeader") {
	case "true":
		q.KnownLeader = true
	default:
		q.KnownLeader = false
	}
	return nil
}
520054
func (e *Ec2Meta) retrieveMetadata(url string, def ...string) (string, error) {
	if value, ok := e.cache[url]; ok {
		return value, nil
	}

	if e.nonAWS {
		return returnDefault(def), nil
	}

	if e.Client == nil {
		timeout := e.options.Timeout
		if timeout == 0 {
			timeout = 500 * time.Millisecond
		}
		e.Client = &http.Client{Timeout: timeout}
	}
	resp, err := e.Client.Get(url)
	if err != nil {
		if unreachable(err) {
			e.nonAWS = true
		}
		return returnDefault(def), nil
	}

	// nolint: errcheck
	defer resp.Body.Close()
	if resp.StatusCode > 399 {
		return returnDefault(def), nil
	}

	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return "", errors.Wrapf(err, "Failed to read response body from %s", url)
	}
	value := strings.TrimSpace(string(body))
	e.cache[url] = value

	return value, nil
}
1127382
func (s *storage) fetchMeta(ctx context.Context, b blob.Ref) (plainSize uint32, encBR blob.Ref, err error) {
	v, err := s.index.Get(b.String())
	if err == sorted.ErrNotFound {
		err = os.ErrNotExist
	}
	if err != nil {
		return 0, blob.Ref{}, err
	}
	return unpackIndexEntry(v)
}
618625
func getMetadata(c context.Context) *metadata.Client {
	return c.Value(&metaKey).(*metadata.Client)
}
38856
func (a *MissingAggregation) Meta(metaData map[string]interface{}) *MissingAggregation {
	a.meta = metaData
	return a
}
79598
func (s *ExtendedStatsBucketAggregation) Meta(metaData map[string]interface{}) *ExtendedStatsBucketAggregation {
	s.meta = metaData
	return s
}
1264623
func (res *Resource) GetMetas([]string) []resource.Metaor {
	metas := []resource.Metaor{}
	for _, meta := range res.Metas {
		metas = append(metas, meta)
	}
	return metas
}
36602
func (s *HTTPServer) parseMetaFilter(req *http.Request) map[string]string {
	if filterList, ok := req.URL.Query()["node-meta"]; ok {
		filters := make(map[string]string)
		for _, filter := range filterList {
			key, value := ParseMetaPair(filter)
			filters[key] = value
		}
		return filters
	}
	return nil
}
323636
func (a *CardinalityAggregation) Meta(metaData map[string]interface{}) *CardinalityAggregation {
	a.meta = metaData
	return a
}
371115
func fetchMeta(meta *Meta, tx *bbolt.Tx) error {
	metaBucket := tx.Bucket(metaBucket)
	if metaBucket == nil {
		return ErrMetaNotFound
	}

	data := metaBucket.Get(dbVersionKey)
	if data == nil {
		meta.DbVersionNumber = getLatestDBVersion(dbVersions)
	} else {
		meta.DbVersionNumber = byteOrder.Uint32(data)
	}

	return nil
}
470214
func (t *tmNodeSeq) WithMeta(meta iseq.PMap) iseq.MetaW {
	return &tmNodeSeq{AMeta: AMeta{meta}, stack: t.stack, asc: t.asc, cnt: t.cnt}
}
1344152
func (s *StatsBucketAggregation) Meta(metaData map[string]interface{}) *StatsBucketAggregation {
	s.meta = metaData
	return s
}
346119
func parseMetadata(md map[string]*string) (map[string]interface{}, error) {
	m := make(map[string]interface{}, len(md))
	for key, value := range md {
		k := strings.ToLower(key)
		m[k] = *value
	}
	return m, nil
}
239605
func (a *BucketScriptAggregation) Meta(metaData map[string]interface{}) *BucketScriptAggregation {
	a.meta = metaData
	return a
}
1001656
func (c *Converter) DefaultMeta(t reflect.Type) (FieldMatchingFlags, *Meta) {
	return c.inputDefaultFlags[t], &Meta{
		KeyNameMapping: c.inputFieldMappingFuncs[t],
	}
}
1214989
func validateMetadata(meta map[string]string) error {
	if len(meta) > metaMaxKeyPairs {
		return fmt.Errorf("metadata cannot contain more than %d key/value pairs", metaMaxKeyPairs)
	}

	for key, value := range meta {
		if err := validateMetaPair(key, value); err != nil {
			return errwrap.Wrapf(fmt.Sprintf("failed to load metadata pair (%q, %q): {{err}}", key, value), err)
		}
	}

	return nil
}
1363605
func (r *SearchResults) Metadata() (*SearchResultsMetadata, error) {
	if !r.streamResult.Closed() {
		return nil, errors.New("result must be closed before accessing meta-data")
	}

	return &r.metadata, nil
}