Samrat002 commented on code in PR #6: URL: https://github.com/apache/flink-connector-redis-streams/pull/6#discussion_r3178566549
########## flink-connector-redis-streams/src/main/java/org/apache/flink/connector/redis/streams/source/reader/split/RedisStreamsSplitReader.java: ########## @@ -0,0 +1,983 @@ +/* + * 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.connector.redis.streams.source.reader.split; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.annotation.VisibleForTesting; +import org.apache.flink.connector.base.source.reader.RecordsWithSplitIds; +import org.apache.flink.connector.base.source.reader.splitreader.SplitReader; +import org.apache.flink.connector.base.source.reader.splitreader.SplitsAddition; +import org.apache.flink.connector.base.source.reader.splitreader.SplitsChange; +import org.apache.flink.connector.redis.streams.source.config.RedisStreamsSourceConfig; +import org.apache.flink.connector.redis.streams.source.config.StartupMode; +import org.apache.flink.connector.redis.streams.source.split.RedisStreamsSourceSplit; + +import io.lettuce.core.AbstractRedisClient; +import io.lettuce.core.ClientOptions; +import io.lettuce.core.Consumer; +import io.lettuce.core.RedisClient; +import io.lettuce.core.RedisConnectionException; +import io.lettuce.core.RedisURI; +import io.lettuce.core.StreamMessage; +import io.lettuce.core.XGroupCreateArgs; +import io.lettuce.core.XReadArgs; +import io.lettuce.core.api.StatefulConnection; +import io.lettuce.core.cluster.ClusterClientOptions; +import io.lettuce.core.cluster.ClusterTopologyRefreshOptions; +import io.lettuce.core.cluster.RedisClusterClient; +import io.lettuce.core.cluster.api.sync.RedisClusterCommands; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.Nullable; + +import java.io.IOException; +import java.time.Duration; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Deque; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.locks.ReentrantLock; + +/** + * Split reader that fetches records from Redis Streams via consumer groups and defers XACK until + * the next completed Flink checkpoint. + */ +@Internal +public class RedisStreamsSplitReader + implements SplitReader<StreamMessage<String, String>, RedisStreamsSourceSplit> { + Review Comment: This is fair. The class does handle connection management, PEL recovery, circuit breaking, deferred ACK tracking, and fetch coordination. Extracting focused classes (RedisConnectionManager, PelRecoveryState, DeferredAckCoordinator, CircuitBreaker) would improve maintainability. That refactoring is exactly the kind of work that should happen once the API is locked and tests are solid, not alongside the initial implementation. I'll file a follow-up for the decomposition. Let me know if follow-up makes sense to keep the scope of this PR limited to the core implementation as 1st version -- 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]
