// LabelLimitKeySize limits the size that a key of a label can be.
169712
func LabelLimitKeySize(size int) Option {
	return func(r *Ringpop) error {
		r.config.LabelLimits.KeySize = size
		return nil
	}
}
1013824
func BatchSizeValue(maxMessages, absoluteMaxBytes, preferredMaxBytes uint32) *StandardConfigValue {
	return &StandardConfigValue{
		key: BatchSizeKey,
		value: &ab.BatchSize{
			MaxMessageCount:   maxMessages,
			AbsoluteMaxBytes:  absoluteMaxBytes,
			PreferredMaxBytes: preferredMaxBytes,
		},
	}
}
441568
func LabelFilterString(key, value string) string {
	return utils.FilterString(map[string][]string{
		"label": {fmt.Sprintf("%s=%s", key, value)},
	})
}
715050
func labels(key string) func(*Status) []string {
	return func(s *Status) []string {
		vs := make([]string, 0, len(s.Labels))
		for _, l := range s.Labels {
			if l.Key == key {
				vs = append(vs, l.Value)
			}
		}
		return vs
	}
}
796256
func (f *Family) AddLabel(key, val string) {
	for i, item := range f.Metrics {
		switch item.(type) {
		case Metric:
			m := item.(Metric)
			m.Labels[key] = val
			f.Metrics[i] = m
		}
	}
}
201803
func (s *CirconusSink) SetGaugeWithLabels(key []string, val float32, labels []metrics.Label) {
	flatKey := s.flattenKeyLabels(key, labels)
	s.metrics.SetGauge(flatKey, int64(val))
}
850092
func Validate(k, v string) error {
	if (len(k) + len(v)) > maxSize {
		if len(k) > 10 {
			k = k[:10]
		}
		return errors.Wrapf(errdefs.ErrInvalidArgument, "label key and value greater than maximum size (%d bytes), key: %s", maxSize, k)
	}
	return nil
}
220289
func ScaledLabel(value int64, fromUnit, toUnit string) string {
	v, u := Scale(value, fromUnit, toUnit)
	sv := strings.TrimSuffix(fmt.Sprintf("%.2f", v), ".00")
	if sv == "0" || sv == "-0" {
		return "0"
	}
	return sv + u
}
1181342
func (cipher CipherFunction) KeySize() int {
	switch cipher {
	case Cipher3DES:
		return 24
	case CipherCAST5:
		return cast5.KeySize
	case CipherAES128:
		return 16
	case CipherAES192:
		return 24
	case CipherAES256:
		return 32
	}
	return 0
}
513395
func LabelValue(name string) string {
	if len(name) <= validation.DNS1123LabelMaxLength {
		return name
	}
	return name[:validation.DNS1123LabelMaxLength]
}
962519
func (c *Checkbox) SetLabelWidth(width int) *Checkbox {
	c.labelWidth = width
	return c
}
1209664
func (ix *Reindexer) BulkSize(bulkSize int) *Reindexer {
	ix.bulkSize = bulkSize
	return ix
}
810567
func CloneAndAddLabel(labels map[string]string, labelKey string, labelValue uint32) map[string]string {
	if labelKey == "" {
		// Dont need to add a label.
		return labels
	}
	// Clone.
	newLabels := map[string]string{}
	for key, value := range labels {
		newLabels[key] = value
	}
	newLabels[labelKey] = fmt.Sprintf("%d", labelValue)
	return newLabels
}
1180906
func ValidateKey(key string) error {
	if len(key) <= keyMaxLength && keyRegex.MatchString(key) {
		return nil
	}
	return fmt.Errorf("invalid key: %q", key)
}
362338
func removeLimit(prop *requiredProperty) *requiredProperty {
	ret := &requiredProperty{
		props:      prop.props,
		sortKeyLen: prop.sortKeyLen,
	}
	return ret
}
93676
func validateLimit(v, min, max int) error {

	// ensure the value for `limit` is valid
	if v < min || v > max {
		err := fmt.Errorf("%d is not a valid value for `limit`, must be between %d-%d (inclusive).", v, min, max)
		return err
	}

	return nil
}
1240511
func appendBatchBySize(b []batchKeys, region RegionVerID, keys [][]byte, sizeFn func([]byte) int, limit int) []batchKeys {
	var start, end int
	for start = 0; start < len(keys); start = end {
		var size int
		for end = start; end < len(keys) && size < limit; end++ {
			size += sizeFn(keys[end])
		}
		b = append(b, batchKeys{
			region: region,
			keys:   keys[start:end],
		})
	}
	return b
}