pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] sijie commented on a change in pull request #3032: Add gRPC proxy
Date Wed, 21 Nov 2018 19:21:32 GMT
sijie commented on a change in pull request #3032: Add gRPC proxy
URL: https://github.com/apache/pulsar/pull/3032#discussion_r235512545
 
 

 ##########
 File path: pulsar-grpc/src/main/java/org/apache/pulsar/grpc/TestClient.java
 ##########
 @@ -0,0 +1,72 @@
+package org.apache.pulsar.grpc;
+
+import com.google.protobuf.ByteString;
+import io.grpc.ManagedChannel;
+import io.grpc.ManagedChannelBuilder;
+import io.grpc.Metadata;
+import io.grpc.stub.MetadataUtils;
+import io.grpc.stub.StreamObserver;
+import org.apache.pulsar.grpc.proto.ConsumerAck;
+import org.apache.pulsar.grpc.proto.ConsumerMessage;
+import org.apache.pulsar.grpc.proto.PulsarGrpc;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.LinkedBlockingQueue;
+
+import static io.grpc.Metadata.ASCII_STRING_MARSHALLER;
+
+public class TestClient {
+
+    public static void main(String[] args) throws Exception {
+        ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 50051)
+                .usePlaintext()
+                .build();
+
+        Metadata headers = new Metadata();
+        headers.put(Metadata.Key.of("pulsar-topic", ASCII_STRING_MARSHALLER), "persistent://public/default/my-topic12");
+        headers.put(Metadata.Key.of("pulsar-subscription", ASCII_STRING_MARSHALLER), "my-subscription");
+        headers.put(Metadata.Key.of("pulsar-subscription-type", ASCII_STRING_MARSHALLER),
"Shared");
+        headers.put(Metadata.Key.of("pulsar-max-redeliver-count", ASCII_STRING_MARSHALLER),
"3");
+        headers.put(Metadata.Key.of("pulsar-ack-timeout-millis", ASCII_STRING_MARSHALLER),
"2000");
+        headers.put(Metadata.Key.of("pulsar-consumer-name", ASCII_STRING_MARSHALLER), "test");
+
+        PulsarGrpc.PulsarStub asyncStub = MetadataUtils.attachHeaders(PulsarGrpc.newStub(channel),
headers);
 
 Review comment:
   per my knowledge of grpc, the metadata header is attached to every request, right? if so,
that sounds very "expensive" to do so.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message