2023-08-28 16:02:12 +00:00
|
|
|
package sub_client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/mq_pb"
|
|
|
|
)
|
|
|
|
|
2023-09-01 07:36:51 +00:00
|
|
|
func (sub *TopicSubscriber) doLookup(brokerAddress string) error {
|
2023-08-28 16:02:12 +00:00
|
|
|
err := pb.WithBrokerGrpcClient(true,
|
|
|
|
brokerAddress,
|
2023-09-05 04:43:50 +00:00
|
|
|
sub.SubscriberConfig.GrpcDialOption,
|
2023-08-28 16:02:12 +00:00
|
|
|
func(client mq_pb.SeaweedMessagingClient) error {
|
|
|
|
lookupResp, err := client.LookupTopicBrokers(context.Background(),
|
|
|
|
&mq_pb.LookupTopicBrokersRequest{
|
|
|
|
Topic: &mq_pb.Topic{
|
2023-09-05 04:43:50 +00:00
|
|
|
Namespace: sub.ContentConfig.Namespace,
|
|
|
|
Name: sub.ContentConfig.Topic,
|
2023-08-28 16:02:12 +00:00
|
|
|
},
|
2023-09-01 07:36:51 +00:00
|
|
|
IsForPublish: false,
|
2023-08-28 16:02:12 +00:00
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2023-09-01 07:36:51 +00:00
|
|
|
sub.brokerPartitionAssignments = lookupResp.BrokerPartitionAssignments
|
2023-08-28 16:02:12 +00:00
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
|
|
|
if err != nil {
|
2023-09-05 04:43:50 +00:00
|
|
|
return fmt.Errorf("lookup topic %s/%s: %v", sub.ContentConfig.Namespace, sub.ContentConfig.Topic, err)
|
2023-08-28 16:02:12 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|