From 85f96e3449e0a2e87a7a7b69fc387950bca2c986 Mon Sep 17 00:00:00 2001 From: stuart nelson Date: Wed, 24 Aug 2016 17:46:46 +0200 Subject: [PATCH] Add comments to exported in types --- types/types.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/types/types.go b/types/types.go index 1059fd11..e147fd27 100644 --- a/types/types.go +++ b/types/types.go @@ -280,29 +280,37 @@ var ( endsAt SortKey = "endsAt" ) +// ByCreatedAt sorts compares CreatedAt times for silences. func ByCreatedAt(i, j *Silence) bool { return i.CreatedAt.After(j.CreatedAt) } +// ByStartsAt sorts compares StartsAt times for silences. func ByStartsAt(i, j *Silence) bool { return i.StartsAt.After(j.StartsAt) } +// ByEndsAt sorts compares EndsAt times for silences. func ByEndsAt(i, j *Silence) bool { return i.EndsAt.After(j.EndsAt) } +// SilenceLessFuncs provides a typesafe way to take user input and select a +// SilencesLessFunc. var SilenceLessFuncs = map[SortKey]SilencesLessFunc{ createdAt: ByCreatedAt, startsAt: ByStartsAt, endsAt: ByEndsAt, } +// SilencesSorter implements the sort interface to sort a slice of silences +// according to less. type SilencesSorter struct { silences []*Silence less SilencesLessFunc } +// NewSilencesSorter returns a new SilencesSorter. func NewSilencesSorter(s []*Silence, fn SilencesLessFunc) *SilencesSorter { return &SilencesSorter{ silences: s,