rmetzger commented on a change in pull request #6594: [FLINK-9311] [pubsub] 
Added PubSub source connector with support for checkpointing (ATLEAST_ONCE)
URL: https://github.com/apache/flink/pull/6594#discussion_r258383131
 
 

 ##########
 File path: 
flink-connectors/flink-connector-pubsub/src/main/java/org/apache/flink/streaming/connectors/pubsub/DefaultPubSubSubscriberFactory.java
 ##########
 @@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.streaming.connectors.pubsub;
+
+import 
org.apache.flink.streaming.connectors.pubsub.common.PubSubSubscriberFactory;
+
+import com.google.api.gax.batching.FlowControlSettings;
+import com.google.api.gax.batching.FlowController;
+import com.google.api.gax.core.FixedCredentialsProvider;
+import com.google.api.gax.grpc.GrpcTransportChannel;
+import com.google.api.gax.rpc.FixedTransportChannelProvider;
+import com.google.api.gax.rpc.TransportChannel;
+import com.google.auth.Credentials;
+import com.google.cloud.pubsub.v1.MessageReceiver;
+import com.google.cloud.pubsub.v1.Subscriber;
+import com.google.pubsub.v1.ProjectSubscriptionName;
+import io.grpc.ManagedChannel;
+import io.grpc.ManagedChannelBuilder;
+
+final class DefaultPubSubSubscriberFactory implements PubSubSubscriberFactory {
+       private String hostAndPort;
+
+       void withHostAndPort(String hostAndPort) {
+               this.hostAndPort = hostAndPort;
+       }
+
+       @Override
+       public Subscriber getSubscriber(Credentials credentials, 
ProjectSubscriptionName projectSubscriptionName, MessageReceiver 
messageReceiver) {
+               FlowControlSettings flowControlSettings = 
FlowControlSettings.newBuilder()
+                       .setMaxOutstandingElementCount(10000L)
+                       .setMaxOutstandingRequestBytes(100000L)
+                       
.setLimitExceededBehavior(FlowController.LimitExceededBehavior.Block)
+                       .build();
+
+               Subscriber.Builder builder = Subscriber
+                               
.newBuilder(ProjectSubscriptionName.of(projectSubscriptionName.getProject(), 
projectSubscriptionName.getSubscription()), messageReceiver)
+                               .setFlowControlSettings(flowControlSettings)
+                               
.setCredentialsProvider(FixedCredentialsProvider.create(credentials));
+
+               if (hostAndPort != null) {
+                       ManagedChannel managedChannel = ManagedChannelBuilder
+                               .forTarget(hostAndPort)
+                               .usePlaintext() // This is 'Ok' because this is 
ONLY used for testing.
 
 Review comment:
   In my experience, some user will eventually need to have everything 
configurable :) There are many esoteric scenarios people are working in :)
   But I'm also okay leaving it as-is for now, and address this in a follow up 
pull request.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to