li4wang commented on code in PR #2320:
URL: https://github.com/apache/zookeeper/pull/2320#discussion_r2621741616


##########
zookeeper-server/src/main/java/org/apache/zookeeper/client/HostConnectionManager.java:
##########
@@ -0,0 +1,391 @@
+/*
+ * 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.zookeeper.client;
+
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import org.apache.yetus.audience.InterfaceAudience;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * HostConnectionManager handles the complex connection management and 
reconfiguration logic
+ */
[email protected]
+public final class HostConnectionManager {

Review Comment:
   I initially implemented it using inheritance but refactored to using the 
composition pattern for the following reasons:
   
   Separation of Concerns: Cleanly separates connection management from DNS 
lookup logic, making each component focused on a single responsibility.
   
   Extensibility: Makes it easy to add new provider types (Consul, etcd, etc.) 
without modifying existing code.
   
   Testability: Makes it easy to test each component independently.
   
   In my opinion, the minimal forwarding/delegation code is easily justified by 
for the improved flexibility, testability, and maintainability this approach 
provides. WDYT?
   
   
   



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