lhotari commented on code in PR #24790:
URL: https://github.com/apache/pulsar/pull/24790#discussion_r2382688101


##########
pulsar-client-api/src/main/java/org/apache/pulsar/client/api/PulsarClientSharedResources.java:
##########
@@ -0,0 +1,110 @@
+/*
+ * 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.pulsar.client.api;
+
+import java.util.Collection;
+import org.apache.pulsar.client.internal.DefaultImplementation;
+
+/**
+ * Manages shared resources across multiple PulsarClient instances to optimize 
resource utilization.
+ * This interface provides access to common resources such as thread pools and 
DNS resolver/cache
+ * that can be shared between multiple PulsarClient instances.
+ *
+ * This allows creating a large number of PulsarClient instances in a single 
JVM without wasting resources.
+ * Sharing the DNS resolver and cache will help reduce the number of DNS 
lookups performed by the clients
+ * and improve latency and reduce load on the DNS servers.
+ *
+ * <p>Key features:
+ * <ul>
+ *   <li>Thread pool sharing for various Pulsar operations (IO, timer, lookup, 
etc.)</li>
+ *   <li>Shared DNS resolver and cache</li>
+ *   <li>Resource lifecycle management</li>
+ * </ul>
+ *
+ * <p>Usage example:
+ * <pre>{@code
+ * // To share all possible resources across multiple PulsarClient instances
+ * PulsarClientSharedResources sharedResources = 
PulsarClientSharedResources.builder()
+ *     .build();
+ * // Use these resources with multiple PulsarClient instances
+ * PulsarClient client1 = 
PulsarClient.builder().sharedResources(sharedResources).build();
+ * PulsarClient client2 = 
PulsarClient.builder().sharedResources(sharedResources).build();
+ * client1.close();
+ * client2.close();
+ * sharedResources.close();
+ * }</pre>
+ *
+ * <p>The instance should be created using the {@link 
PulsarClientSharedResourcesBuilder},
+ * which can be obtained via the {@link #builder()} method.
+ *
+ * @see PulsarClientSharedResourcesBuilder
+ * @see ResourceType
+ */
+public interface PulsarClientSharedResources extends AutoCloseable {
+    enum ResourceType {
+        // pulsar-io threadpool
+        eventLoopGroup,
+        // pulsar-timer threadpool
+        timer,
+        // pulsar-client-internal threadpool
+        internalExecutor,
+        // pulsar-external-listener threadpool
+        externalExecutor,
+        // pulsar-client-scheduled threadpool
+        scheduledExecutor,
+        // pulsar-lookup threadpool
+        lookupExecutor,
+        // DNS resolver and cache that must be shared together with 
eventLoopGroup
+        dnsResolver

Review Comment:
   I switched to capitalized camel case since it's broadly used in the code 
base.



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