showuon commented on a change in pull request #11775:
URL: https://github.com/apache/kafka/pull/11775#discussion_r820022615



##########
File path: 
connect/api/src/main/java/org/apache/kafka/connect/source/SourceConnector.java
##########
@@ -28,4 +30,46 @@
     protected SourceConnectorContext context() {
         return (SourceConnectorContext) context;
     }
+
+    /**
+     * Signals whether the connector supports exactly-once delivery guarantees 
with a proposed configuration.
+     * Developers can assume that worker-level exactly-once support is enabled 
when this method is invoked.
+     *
+     * <p>For backwards compatibility, the default implementation will return 
{@code null}, but connector developers are
+     * strongly encouraged to override this method to return a non-null value 
such as
+     * {@link ExactlyOnceSupport#SUPPORTED SUPPORTED} or {@link 
ExactlyOnceSupport#UNSUPPORTED UNSUPPORTED}.
+     *
+     * <p>Similar to {@link #validate(Map) validate}, this method may be 
called by the runtime before the
+     * {@link #start(Map) start} method is invoked when the connector will be 
run with exactly-once support.
+     *
+     * @param connectorConfig the configuration that will be used for the 
connector.
+     * @return {@link ExactlyOnceSupport#SUPPORTED} if the connector can 
provide exactly-once support with the given
+     * configuration, and {@link ExactlyOnceSupport#UNSUPPORTED} if it cannot. 
If this method is overridden by a
+     * connector, should not be {@code null}, but if {@code null}, it will be 
assumed that the connector cannot provide
+     * exactly-once guarantees.
+     * @since 3.2
+     */
+    public ExactlyOnceSupport exactlyOnceSupport(Map<String, String> 
connectorConfig) {
+        return null;
+    }
+
+    /**
+     * Signals whether the connector implementation is capable of defining the 
transaction boundaries for a
+     * connector with the given configuration. This method is called before 
{@link #start(Map)}, only when the
+     * runtime supports exactly-once and the connector configuration includes 
{@code transaction.boundary=connector}.
+     *
+     * <p>This method need not be implemented if the connector implementation 
does not support defining
+     * transaction boundaries.
+     *
+     * @param connectorConfig the configuration that will be used for the 
connector
+     * @return {@link ConnectorTransactionBoundaries#SUPPORTED} if the 
connector will define its own transaction boundaries,
+     * or {@link ConnectorTransactionBoundaries#UNSUPPORTED} otherwise. If 
this method is overridden by a
+     * connector, should not be {@code null}, but if {@code null}, it will be 
assumed that the connector cannot define its own
+     * transaction boundaries.

Review comment:
       > Thoughts on prohibiting null as a return value and both documenting 
that fact here and adding a preflight validation step to enforce it?
   
   Sounds good to me. Thanks for the explanation!




-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to