Merge pull request #1901 from simonpasquier/refactor-marker-count
types: refactor *memMarker.Count method
This commit is contained in:
commit
b783cf8e60
|
@ -128,14 +128,14 @@ func (m *memMarker) registerMetrics(r prometheus.Registerer) {
|
||||||
|
|
||||||
// Count implements Marker.
|
// Count implements Marker.
|
||||||
func (m *memMarker) Count(states ...AlertState) int {
|
func (m *memMarker) Count(states ...AlertState) int {
|
||||||
count := 0
|
|
||||||
|
|
||||||
m.mtx.RLock()
|
m.mtx.RLock()
|
||||||
defer m.mtx.RUnlock()
|
defer m.mtx.RUnlock()
|
||||||
|
|
||||||
if len(states) == 0 {
|
if len(states) == 0 {
|
||||||
count = len(m.m)
|
return len(m.m)
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
var count int
|
||||||
for _, status := range m.m {
|
for _, status := range m.m {
|
||||||
for _, state := range states {
|
for _, state := range states {
|
||||||
if status.State == state {
|
if status.State == state {
|
||||||
|
@ -143,7 +143,6 @@ func (m *memMarker) Count(states ...AlertState) int {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return count
|
return count
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue