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