read existing broker stats

This commit is contained in:
chrislu 2023-09-24 23:10:33 -07:00
parent 1492bf7552
commit dff2ce5d2f

View file

@ -20,11 +20,15 @@ func (broker *MessageQueueBroker) ConnectToBalancer(stream mq_pb.SeaweedMessagin
// process init message
initMessage := req.GetInit()
brokerStats := balancer.NewBrokerStats()
var brokerStats *balancer.BrokerStats
if initMessage != nil {
broker.Balancer.Brokers.Set(initMessage.Broker, brokerStats)
var found bool
brokerStats, found = broker.Balancer.Brokers.Get(initMessage.Broker)
if !found {
brokerStats = balancer.NewBrokerStats()
broker.Balancer.Brokers.Set(initMessage.Broker, brokerStats)
}
} else {
// TODO fix this
return status.Errorf(codes.InvalidArgument, "balancer init message is empty")
}
defer func() {