fapaul commented on a change in pull request #16676:
URL: https://github.com/apache/flink/pull/16676#discussion_r683305461



##########
File path: 
flink-connectors/flink-connector-kafka/src/main/java/org/apache/flink/streaming/connectors/kafka/sink/KafkaSinkBuilder.java
##########
@@ -0,0 +1,187 @@
+/*
+ * 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.kafka.sink;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.java.ClosureCleaner;
+import org.apache.flink.connector.base.DeliveryGuarantee;
+
+import org.apache.kafka.clients.producer.ProducerConfig;
+import org.apache.kafka.common.serialization.ByteArraySerializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.time.Duration;
+import java.util.Properties;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+import static org.apache.flink.util.Preconditions.checkState;
+
+/**
+ * Builder to construct {@link KafkaSink}.
+ *
+ * <p>The following example shows the minimum setup to create a KafkaSink that 
writes String values
+ * to a Kafka topic.
+ *
+ * <pre>{@code
+ * KafkaSink<String> sink = KafkaSink
+ *     .<String>builder
+ *     .setBootstrapServers(MY_BOOTSTRAP_SERVERS)
+ *     .setRecordSerializer(MY_RECORD_SERIALIZER)
+ *     .setKafkaProducerConfig(MY_PRODUCER_CONFIG)
+ *     .build();
+ * }</pre>
+ *
+ * <p>One can also configure different {@link DeliveryGuarantee} by using 
{@link
+ * #setDeliverGuarantee(DeliveryGuarantee)} but keep in mind when using {@link
+ * DeliveryGuarantee#EXACTLY_ONCE} one must set the transactionalIdPrefix 
{@link
+ * #setTransactionalIdPrefix(String)}.
+ *
+ * @param <IN> type of the records written to Kafka
+ */
+public class KafkaSinkBuilder<IN> {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(KafkaSinkBuilder.class);
+    private static final Duration DEFAULT_KAFKA_TRANSACTION_TIMEOUT = 
Duration.ofHours(1);
+
+    private DeliveryGuarantee deliveryGuarantee = DeliveryGuarantee.NONE;
+    private String transactionalIdPrefix = "kafka-sink";
+
+    private Properties kafkaProducerConfig;
+    private KafkaRecordSerializationSchema<IN> recordSerializer;
+    private String bootstrapServers;
+
+    /**
+     * Sets the wanted the {@link DeliveryGuarantee}. The default delivery 
guarantee is {@link
+     * #deliveryGuarantee}.
+     *
+     * @param deliveryGuarantee
+     * @return {@link KafkaSinkBuilder}
+     */
+    KafkaSinkBuilder<IN> setDeliverGuarantee(DeliveryGuarantee 
deliveryGuarantee) {
+        this.deliveryGuarantee = checkNotNull(deliveryGuarantee, "semantic");

Review comment:
       I will definitely leave the second parameter out next time but now I 
want to keep it consistent.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to