mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-04-24 18:59:34 +08:00
29 lines
791 B
Go
29 lines
791 B
Go
![]() |
package sub_client
|
||
|
|
||
|
import (
|
||
|
cmap "github.com/orcaman/concurrent-map"
|
||
|
"github.com/rdleal/intervalst/interval"
|
||
|
"github.com/seaweedfs/seaweedfs/weed/pb/mq_pb"
|
||
|
)
|
||
|
|
||
|
type SubscriberConfiguration struct {
|
||
|
}
|
||
|
|
||
|
type TopicSubscriber struct {
|
||
|
namespace string
|
||
|
topic string
|
||
|
partition2Broker *interval.SearchTree[string, int32]
|
||
|
broker2PublishClient cmap.ConcurrentMap[string, mq_pb.SeaweedMessaging_PublishClient]
|
||
|
}
|
||
|
|
||
|
func NewTopicSubscriber(config *SubscriberConfiguration, namespace, topic string) *TopicSubscriber {
|
||
|
return &TopicSubscriber{
|
||
|
namespace: namespace,
|
||
|
topic: topic,
|
||
|
partition2Broker: interval.NewSearchTree[string](func(a, b int32) int {
|
||
|
return int(a - b)
|
||
|
}),
|
||
|
broker2PublishClient: cmap.New[mq_pb.SeaweedMessaging_PublishClient](),
|
||
|
}
|
||
|
}
|