broker_grpc_admin.go 700 B

1234567891011121314151617181920212223
  1. package broker
  2. import (
  3. "context"
  4. "github.com/seaweedfs/seaweedfs/weed/mq/pub_balancer"
  5. "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
  6. "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb"
  7. )
  8. func (b *MessageQueueBroker) FindBrokerLeader(c context.Context, request *mq_pb.FindBrokerLeaderRequest) (*mq_pb.FindBrokerLeaderResponse, error) {
  9. ret := &mq_pb.FindBrokerLeaderResponse{}
  10. err := b.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
  11. resp, err := client.FindLockOwner(context.Background(), &filer_pb.FindLockOwnerRequest{
  12. Name: pub_balancer.LockBrokerBalancer,
  13. })
  14. if err != nil {
  15. return err
  16. }
  17. ret.Broker = resp.Owner
  18. return nil
  19. })
  20. return ret, err
  21. }