yuxiqian commented on code in PR #4409: URL: https://github.com/apache/flink-cdc/pull/4409#discussion_r3663587640
########## flink-cdc-common/src/main/java/org/apache/flink/cdc/common/source/discover/TableDiscoverer.java: ########## @@ -0,0 +1,82 @@ +/* + * 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.cdc.common.source.discover; + +import org.apache.flink.cdc.common.annotation.PublicEvolving; +import org.apache.flink.cdc.common.configuration.Configuration; +import org.apache.flink.cdc.common.event.TableId; + +import java.io.Serializable; +import java.util.Set; + +/** + * Pluggable abstraction for discovering a set of tables that a source connector should read. + * Implementations are loaded via SPI through {@link TableDiscovererFactory} and determine which + * tables the source should subscribe to. + * + * <p>Lifecycle: {@link #open(Context)} is called once before the first call to {@link #discover()}. + * {@link #close()} is called when the discoverer is no longer needed. Implementations manage their + * own resources (e.g., connections) within this lifecycle. + * + * <p>Built-in implementations include: + * + * <ul> + * <li>{@link JdbcTableDiscoverer} - reads the subscription list from a JDBC database table. + * </ul> + */ +@PublicEvolving +public interface TableDiscoverer extends Serializable, AutoCloseable { + + /** + * Opens this discoverer and initializes any resources needed for table discovery. + * + * @param context The context providing configuration and class loader. + * @throws Exception if initialization fails. + */ + void open(Context context) throws Exception; + + /** + * Discovers and returns the set of tables to subscribe to. + * + * @return A set of {@link TableId} representing the tables to read. + * @throws Exception if the discovery fails. + */ + Set<TableId> discover() throws Exception; Review Comment: Maybe rename `TableDiscoverer` => `ObjectDiscoverer`, too? -- 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]
