blob: 4c5f8f3c885e3681542fdf607310bf1b7468cf67 (
plain)
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
|
package balancer
import (
"fmt"
cmap "github.com/orcaman/concurrent-map/v2"
)
type Balancer struct {
Brokers cmap.ConcurrentMap[string, *BrokerStats]
}
type BrokerStats struct {
TopicPartitionCount int32
MessageCount int64
BytesCount int64
CpuUsagePercent int32
}
type TopicPartition struct {
Topic string
RangeStart int32
RangeStop int32
}
type TopicPartitionStats struct {
TopicPartition
Throughput int64
ConsumerCount int64
TopicPartitionCount int64
}
func NewBalancer() *Balancer {
return &Balancer{
Brokers: cmap.New[*BrokerStats](),
}
}
func NewBrokerStats() *BrokerStats {
return &BrokerStats{}
}
func (tp *TopicPartition) String() string {
return fmt.Sprintf("%v-%04d-%04d", tp.Topic, tp.RangeStart, tp.RangeStop)
}
|