-
Notifications
You must be signed in to change notification settings - Fork 11
/
utils.go
49 lines (39 loc) · 926 Bytes
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Gardener contributors
//
// SPDX-License-Identifier: Apache-2.0
package nwpd
import (
"sort"
"time"
)
type ObservationListener interface {
Add(obs *Observation)
}
type ListObservationsOptions struct {
Start time.Time
End time.Time
Limit int
FilterJobIDs []string
FilterSrcHosts []string
FilterDestHosts []string
FailuresOnly bool
}
type ObservationWriter interface {
ObservationListener
Run()
Stop()
ListObservations(options ListObservationsOptions) (Observations, error)
}
type Observations []*Observation
var _ sort.Interface = Observations{}
func (o Observations) Len() int {
return len(o)
}
func (o Observations) Less(i, j int) bool {
ti := o[i].Timestamp.AsTime()
tj := o[j].Timestamp.AsTime()
return ti.Before(tj)
}
func (o Observations) Swap(i, j int) {
o[i], o[j] = o[j], o[i]
}