can pub and sub

This commit is contained in:
chrislu
2023-09-01 00:36:51 -07:00
parent 1eb2da46d5
commit cb470d44df
11 changed files with 435 additions and 275 deletions

View File

@@ -15,6 +15,7 @@ type TopicPublisher struct {
topic string
partition2Broker *interval.SearchTree[string, int32]
broker2PublishClient cmap.ConcurrentMap[string, mq_pb.SeaweedMessaging_PublishClient]
grpcDialOption grpc.DialOption
}
func NewTopicPublisher(namespace, topic string) *TopicPublisher {
@@ -25,11 +26,12 @@ func NewTopicPublisher(namespace, topic string) *TopicPublisher {
return int(a - b)
}),
broker2PublishClient: cmap.New[mq_pb.SeaweedMessaging_PublishClient](),
grpcDialOption: grpc.WithTransportCredentials(insecure.NewCredentials()),
}
}
func (p *TopicPublisher) Connect(bootstrapBroker string) error {
if err := p.doLookup(bootstrapBroker, grpc.WithTransportCredentials(insecure.NewCredentials())); err != nil {
if err := p.doLookup(bootstrapBroker); err != nil {
return err
}
return nil