MCPcopy
hub / github.com/grafana/dskit / countPartitionsByState

Method countPartitionsByState

ring/partition_ring_model.go:141–157  ·  view source on GitHub ↗

countPartitionsByState returns a map containing the number of partitions by state.

()

Source from the content-addressed store, hash-verified

139
140// countPartitionsByState returns a map containing the number of partitions by state.
141func (m *PartitionRingDesc) countPartitionsByState() map[PartitionState]int {
142 // Init the map to have to zero values for all states.
143 out := make(map[PartitionState]int, len(PartitionState_value)-2)
144 for _, state := range PartitionState_value {
145 if PartitionState(state) == PartitionUnknown || PartitionState(state) == PartitionDeleted {
146 continue
147 }
148
149 out[PartitionState(state)] = 0
150 }
151
152 for _, partition := range m.Partitions {
153 out[partition.State]++
154 }
155
156 return out
157}
158
159func (m *PartitionRingDesc) activePartitionsCount() int {
160 count := 0

Calls 1

PartitionStateTypeAlias · 0.85