Add sortable target list

This commit is contained in:
Fabian Reinartz 2016-03-02 09:10:20 +01:00
parent 2c931950c6
commit ddc74f712b

View File

@ -221,6 +221,13 @@ func (t *Target) Health() TargetHealth {
return t.health return t.health
} }
// Targets is a sortable list of targets.
type Targets []*Target
func (ts Targets) Len() int { return len(ts) }
func (ts Targets) Less(i, j int) bool { return ts[i].URL().String() < ts[j].URL().String() }
func (ts Targets) Swap(i, j int) { ts[i], ts[j] = ts[j], ts[i] }
// Merges the ingested sample's metric with the label set. On a collision the // Merges the ingested sample's metric with the label set. On a collision the
// value of the ingested label is stored in a label prefixed with 'exported_'. // value of the ingested label is stored in a label prefixed with 'exported_'.
type ruleLabelsAppender struct { type ruleLabelsAppender struct {