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



##########
File path: 
flink-core/src/main/java/org/apache/flink/api/connector/sink2/Sink.java
##########
@@ -0,0 +1,106 @@
+/*
+ * 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.api.connector.sink2;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.api.common.operators.MailboxExecutor;
+import org.apache.flink.api.common.operators.ProcessingTimeService;
+import org.apache.flink.api.common.serialization.SerializationSchema;
+import org.apache.flink.metrics.groups.SinkWriterMetricGroup;
+import org.apache.flink.util.UserCodeClassLoader;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.OptionalLong;
+
+/**
+ * Base interface for developing a sink. A basic {@link Sink} is a stateless 
sink that can flush
+ * data on checkpoint to achieve at-least-once consistency. Sinks with 
additional requirements
+ * should implement {@link StatefulSink} or {@link TwoPhaseCommittingSink}.
+ *
+ * <p>The {@link Sink} needs to be serializable. All configuration should be 
validated eagerly. The
+ * respective sink writers are transient and will only be created in the 
subtasks on the
+ * taskmanagers.
+ *
+ * @param <InputT> The type of the sink's input
+ */
+@PublicEvolving
+public interface Sink<InputT> extends Serializable {
+
+    /**
+     * Create a {@link SinkWriter}.
+     *
+     * @param context the runtime context.
+     * @return A sink writer.
+     * @throws IOException for any failure during creation.
+     */
+    SinkWriter<InputT> createWriter(InitContext context) throws IOException;
+
+    /** The interface exposes some runtime info for creating a {@link 
SinkWriter}. */
+    @PublicEvolving
+    interface InitContext {
+        /** The first checkpoint id when an application is started. */
+        long INITIAL_CHECKPOINT_ID = 1;

Review comment:
       Unfortunately, our codebase does not offer a publicly accessible place 
yet on how to retrieve the first checkpoint number (without recovery). 
Previously I used this [1] but it violates the architectural rules because 
`CheckpointIDCointer` is not public and probably will never be. 
   I clarify in the docstring that this is the checkpoint id if the job is not 
recovering.
   
   [1] 
https://github.com/apache/flink/blob/44fea94ca2ed46facd0708c4a7f8b7555fa09c71/flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/CheckpointIDCounter.java#L25




-- 
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