// parseQueryMeta is used to help parse query meta-data
//
// TODO(rb): bug? the error from this function is never handled
7557
func parseQueryMeta(resp *http.Response, q *QueryMeta) error {
	header := resp.Header

	// Parse the X-Consul-Index (if it's set - hash based blocking queries don't
	// set this)
	if indexStr := header.Get("X-Consul-Index"); indexStr != "" {
		index, err := strconv.ParseUint(indexStr, 10, 64)
		if err != nil {
			return fmt.Errorf("Failed to parse X-Consul-Index: %v", err)
		}
		q.LastIndex = index
	}
	q.LastContentHash = header.Get("X-Consul-ContentHash")

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

	// Parse the X-Consul-KnownLeader
	switch header.Get("X-Consul-KnownLeader") {
	case "true":
		q.KnownLeader = true
	default:
		q.KnownLeader = false
	}

	// Parse X-Consul-Translate-Addresses
	switch header.Get("X-Consul-Translate-Addresses") {
	case "true":
		q.AddressTranslationEnabled = true
	default:
		q.AddressTranslationEnabled = false
	}

	// Parse Cache info
	if cacheStr := header.Get("X-Cache"); cacheStr != "" {
		q.CacheHit = strings.EqualFold(cacheStr, "HIT")
	}
	if ageStr := header.Get("Age"); ageStr != "" {
		age, err := strconv.ParseUint(ageStr, 10, 64)
		if err != nil {
			return fmt.Errorf("Failed to parse Age Header: %v", err)
		}
		q.CacheAge = time.Duration(age) * time.Second
	}

	return nil
}
1351125
func (c *chunkedSeq) WithMeta(meta iseq.PMap) iseq.MetaW {
	if meta == c.meta {
		return c
	}
	return newChunkedSeqM(meta, c.vec, c.node, c.idx, c.offset)
}
1131948
func (a *MovAvgAggregation) Meta(metaData map[string]interface{}) *MovAvgAggregation {
	a.meta = metaData
	return a
}
1134902
func ValidateMetadata(meta map[string]string, allowConsulPrefix bool) error {
	if len(meta) > metaMaxKeyPairs {
		return fmt.Errorf("Node metadata cannot contain more than %d key/value pairs", metaMaxKeyPairs)
	}

	for key, value := range meta {
		if err := validateMetaPair(key, value, allowConsulPrefix); err != nil {
			return fmt.Errorf("Couldn't load metadata pair ('%s', '%s'): %s", key, value, err)
		}
	}

	return nil
}
293441
func (a *RangeAggregation) Meta(metaData map[string]interface{}) *RangeAggregation {
	a.meta = metaData
	return a
}
353696
func (s *IssueService) GetCreateMeta(projectkeys string) (*CreateMetaInfo, *Response, error) {
	return s.GetCreateMetaWithOptions(&GetQueryOptions{ProjectKeys: projectkeys, Expand: "projects.issuetypes.fields"})
}
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
}
38856
func (a *MissingAggregation) Meta(metaData map[string]interface{}) *MissingAggregation {
	a.meta = metaData
	return a
}
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)
}
518610
func parseGWMetaMap(gwMetaBuf []byte) map[string]string {
	// Get gwMetaV1.Meta map.
	metaMapResult := gjson.GetBytes(gwMetaBuf, "meta").Map()
	metaMap := make(map[string]string)
	for key, valResult := range metaMapResult {
		metaMap[key] = valResult.String()
	}
	return metaMap
}
710866
func (s *Plugin) GetMeta() v1.Meta {
	return v1.Meta{
		Name: "aws",
		Properties: map[string]interface{}{
			"version": s.PluginVersion,
		},
	}
}
1272798
func (a *FiltersAggregation) Meta(metaData map[string]interface{}) *FiltersAggregation {
	a.meta = metaData
	return a
}
300720
func (a *SamplerAggregation) Meta(metaData map[string]interface{}) *SamplerAggregation {
	a.meta = metaData
	return a
}
1360355
func parseMetadata(ctx context.Context, path, scheme string) (string, string, string, error) {
	rc, err := fetchMetadata(ctx, path, scheme)
	if err != nil {
		return "", "", "", err
	}
	defer rc.Close()

	imports, err := parseMetaGoImports(rc)
	if err != nil {
		return "", "", "", err
	}
	match := -1
	for i, im := range imports {
		if !strings.HasPrefix(path, im.Prefix) {
			continue
		}
		if match != -1 {
			return "", "", "", fmt.Errorf("multiple meta tags match import path %q", path)
		}
		match = i
	}
	if match == -1 {
		return "", "", "", fmt.Errorf("go-import metadata not found")
	}
	return imports[match].Prefix, imports[match].VCS, imports[match].RepoRoot, nil
}
660615
func (r Router) parseQueryPart(queryPart string) (params map[string][]string) {
	var err error
	params, err = url.ParseQuery(queryPart)
	if err != nil && r.Verbose {
		// the URL spec allows things other than name/value pairs in the query
		// part of the URL, so we optionally log a message
		log.Printf("Error parsing query %v: %v", queryPart, err)
	}
	return
}
331092
func (a *ExtendedStatsAggregation) Meta(metaData map[string]interface{}) *ExtendedStatsAggregation {
	a.meta = metaData
	return a
}
1295941
func parseMeta(videoID, queryString string) (glod.Response, error) {
	var song glod.Response

	u, _ := url.Parse("?" + queryString)
	query := u.Query()

	if query.Get("errorcode") != "" || query.Get("status") == "fail" {
		return song, errors.New(query.Get("reason"))
	}

	song.Title = query.Get("title")
	song.Artist = query.Get("author")

	formatParam := strings.Split(query.Get("url_encoded_fmt_stream_map"), ",")
	var formats []Format
	for _, f := range formatParam {
		furl, _ := url.Parse("?" + f)
		fquery := furl.Query()

		itag, _ := strconv.Atoi(fquery.Get("itag"))

		formats = append(
			formats,
			Format{
				Itag:      itag,
				VideoType: fquery.Get("type"),
				Quality:   fquery.Get("quality"),
				URL:       fquery.Get("url"),
			})
	}
	if strings.Contains(formats[0].URL, "signature=") {
		song.StreamURL = formats[0].URL
	}
	return song, nil
}