|
@ -19,6 +19,8 @@ var ( |
|
|
namespace = flag.String("ns", "test", "namespace") |
|
|
namespace = flag.String("ns", "test", "namespace") |
|
|
t = flag.String("topic", "test", "topic") |
|
|
t = flag.String("topic", "test", "topic") |
|
|
seedBrokers = flag.String("brokers", "localhost:17777", "seed brokers") |
|
|
seedBrokers = flag.String("brokers", "localhost:17777", "seed brokers") |
|
|
|
|
|
maxPartitionCount = flag.Int("maxPartitionCount", 3, "max partition count") |
|
|
|
|
|
perPartitionConcurrency = flag.Int("perPartitionConcurrency", 1, "per partition concurrency") |
|
|
|
|
|
|
|
|
clientId = flag.Uint("client_id", uint(util.RandomInt32()), "client id") |
|
|
clientId = flag.Uint("client_id", uint(util.RandomInt32()), "client id") |
|
|
) |
|
|
) |
|
@ -54,6 +56,8 @@ func main() { |
|
|
ConsumerGroup: "test", |
|
|
ConsumerGroup: "test", |
|
|
ConsumerGroupInstanceId: fmt.Sprintf("client-%d", *clientId), |
|
|
ConsumerGroupInstanceId: fmt.Sprintf("client-%d", *clientId), |
|
|
GrpcDialOption: grpc.WithTransportCredentials(insecure.NewCredentials()), |
|
|
GrpcDialOption: grpc.WithTransportCredentials(insecure.NewCredentials()), |
|
|
|
|
|
MaxPartitionCount: int32(*maxPartitionCount), |
|
|
|
|
|
PerPartitionConcurrency: int32(*perPartitionConcurrency), |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
contentConfig := &sub_client.ContentConfiguration{ |
|
|
contentConfig := &sub_client.ContentConfiguration{ |
|
@ -62,13 +66,8 @@ func main() { |
|
|
StartTime: time.Unix(1, 1), |
|
|
StartTime: time.Unix(1, 1), |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
processorConfig := sub_client.ProcessorConfiguration{ |
|
|
|
|
|
MaxPartitionCount: 3, |
|
|
|
|
|
PerPartitionConcurrency: 1, |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
brokers := strings.Split(*seedBrokers, ",") |
|
|
brokers := strings.Split(*seedBrokers, ",") |
|
|
subscriber := sub_client.NewTopicSubscriber(brokers, subscriberConfig, contentConfig, processorConfig) |
|
|
|
|
|
|
|
|
subscriber := sub_client.NewTopicSubscriber(brokers, subscriberConfig, contentConfig) |
|
|
|
|
|
|
|
|
counter := 0 |
|
|
counter := 0 |
|
|
subscriber.SetEachMessageFunc(func(key, value []byte) error { |
|
|
subscriber.SetEachMessageFunc(func(key, value []byte) error { |
|
@ -76,6 +75,7 @@ func main() { |
|
|
record := &schema_pb.RecordValue{} |
|
|
record := &schema_pb.RecordValue{} |
|
|
proto.Unmarshal(value, record) |
|
|
proto.Unmarshal(value, record) |
|
|
fmt.Printf("record: %v\n", record) |
|
|
fmt.Printf("record: %v\n", record) |
|
|
|
|
|
time.Sleep(1300 * time.Millisecond) |
|
|
return nil |
|
|
return nil |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|