2022-07-11 03:11:37 +08:00
|
|
|
package broker
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-02-06 15:14:25 +08:00
|
|
|
"github.com/seaweedfs/seaweedfs/weed/mq/pub_balancer"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
2022-07-29 15:17:28 +08:00
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/mq_pb"
|
2022-07-11 03:11:37 +08:00
|
|
|
)
|
|
|
|
|
2023-12-12 04:05:54 +08:00
|
|
|
func (b *MessageQueueBroker) FindBrokerLeader(c context.Context, request *mq_pb.FindBrokerLeaderRequest) (*mq_pb.FindBrokerLeaderResponse, error) {
|
2022-07-11 15:20:27 +08:00
|
|
|
ret := &mq_pb.FindBrokerLeaderResponse{}
|
2024-02-06 15:14:25 +08:00
|
|
|
err := b.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
|
|
|
resp, err := client.FindLockOwner(context.Background(), &filer_pb.FindLockOwnerRequest{
|
|
|
|
Name: pub_balancer.LockBrokerBalancer,
|
2022-07-11 15:20:27 +08:00
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2024-02-06 15:14:25 +08:00
|
|
|
ret.Broker = resp.Owner
|
2022-07-11 15:20:27 +08:00
|
|
|
return nil
|
|
|
|
})
|
|
|
|
return ret, err
|
|
|
|
}
|