-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
check.go
54 lines (43 loc) · 970 Bytes
/
check.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
50
51
52
53
54
package health
import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// Check tracks resource health.
type Check struct {
Counts
GVR string
}
// Checks represents a collection of health checks.
type Checks []*Check
// NewCheck returns a new health check.
func NewCheck(gvr string) *Check {
return &Check{
GVR: gvr,
Counts: make(Counts),
}
}
// Set sets a health metric.
func (c *Check) Set(l Level, v int64) {
c.Counts[l] = v
}
// Inc increments a health metric.
func (c *Check) Inc(l Level) {
c.Counts[l]++
}
// Total stores a metric total.
func (c *Check) Total(n int64) {
c.Counts[Corpus] = n
}
// Tally retrieves a given health metric.
func (c *Check) Tally(l Level) int64 {
return c.Counts[l]
}
// GetObjectKind returns a schema object.
func (Check) GetObjectKind() schema.ObjectKind {
return nil
}
// DeepCopyObject returns a container copy.
func (c Check) DeepCopyObject() runtime.Object {
return c
}