adjust publisher subscriber

This commit is contained in:
chrislu 2024-01-15 20:42:46 -08:00
parent 026c54a9bb
commit 7e6497cc1c
2 changed files with 10 additions and 6 deletions

View File

@ -12,7 +12,8 @@ import (
var (
messageCount = flag.Int("n", 1000, "message count")
concurrency = flag.Int("c", 4, "concurrency count")
concurrency = flag.Int("c", 4, "concurrent publishers")
partitionCount = flag.Int("p", 6, "partition count")
namespace = flag.String("ns", "test", "namespace")
topic = flag.String("topic", "test", "topic")
@ -39,7 +40,7 @@ func main() {
flag.Parse()
config := &pub_client.PublisherConfiguration{
CreateTopic: true,
CreateTopicPartitionCount: 1,
CreateTopicPartitionCount: int32(*partitionCount),
}
publisher := pub_client.NewTopicPublisher(*namespace, *topic, config)
brokers := strings.Split(*seedBrokers, ",")

View File

@ -5,6 +5,7 @@ import (
"fmt"
"github.com/seaweedfs/seaweedfs/weed/glog"
"github.com/seaweedfs/seaweedfs/weed/mq/client/sub_client"
"github.com/seaweedfs/seaweedfs/weed/util"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"strings"
@ -15,15 +16,17 @@ var (
namespace = flag.String("ns", "test", "namespace")
topic = flag.String("topic", "test", "topic")
seedBrokers = flag.String("brokers", "localhost:17777", "seed brokers")
clientId = flag.Uint("client_id", uint(util.RandomInt32()), "client id")
)
func main() {
flag.Parse()
subscriberConfig := &sub_client.SubscriberConfiguration{
ClientId: "testSubscriber",
ClientId: fmt.Sprintf("client-%d", *clientId),
ConsumerGroup: "test",
ConsumerGroupInstanceId: "test",
ConsumerGroupInstanceId: fmt.Sprintf("client-%d", *clientId),
GrpcDialOption: grpc.WithTransportCredentials(insecure.NewCredentials()),
}
@ -35,7 +38,7 @@ func main() {
}
processorConfig := sub_client.ProcessorConfiguration{
ConcurrentPartitionLimit: 6,
ConcurrentPartitionLimit: 3,
}
brokers := strings.Split(*seedBrokers, ",")