You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
943 B

  1. package sub_client
  2. import (
  3. "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb"
  4. "google.golang.org/grpc"
  5. "google.golang.org/grpc/credentials/insecure"
  6. )
  7. type SubscriberConfiguration struct {
  8. ConsumerGroup string
  9. ConsumerId string
  10. }
  11. type TopicSubscriber struct {
  12. config *SubscriberConfiguration
  13. namespace string
  14. topic string
  15. brokerPartitionAssignments []*mq_pb.BrokerPartitionAssignment
  16. grpcDialOption grpc.DialOption
  17. }
  18. func NewTopicSubscriber(config *SubscriberConfiguration, namespace, topic string) *TopicSubscriber {
  19. return &TopicSubscriber{
  20. config: config,
  21. namespace: namespace,
  22. topic: topic,
  23. grpcDialOption: grpc.WithTransportCredentials(insecure.NewCredentials()),
  24. }
  25. }
  26. func (sub *TopicSubscriber) Connect(bootstrapBroker string) error {
  27. if err := sub.doLookup(bootstrapBroker); err != nil {
  28. return err
  29. }
  30. return nil
  31. }