lhotari opened a new issue, #24795:
URL: https://github.com/apache/pulsar/issues/24795

   ### Search before reporting
   
   - [x] I searched in the [issues](https://github.com/apache/pulsar/issues) 
and found nothing similar.
   
   
   ### Motivation
   
   PIP-234 implementation #24790 adds support for sharing thread pools and DNS 
resolver/cache across multiple client instances. However, authentication 
implementations such as AuthenticationOAuth2 create new thread pools and DNS 
resolvers/caches. This isn't desired, since it would be useful to be able to 
share the Netty Event Loop and configure the DNS settings in the client and use 
them for all Pulsar client DNS lookups, at least for most common use cases.
   
   ### Solution
   
   The org.apache.pulsar.client.api.Authentication interface could be changed 
so that the "container" could pass a context instance with contains methods to 
lookup shared instances.
   ```java
       /**
        * Initialize the authentication provider.
        */
       default void start(AuthenticationInitContext context) throws 
PulsarClientException {
           start();
       }
   
       /**
        * Initialize the authentication provider.
        */
       void start() throws PulsarClientException;
   ```
   
   The AuthenticationInitContext could contain generic "getService" and 
"getServiceByName" methods:
   ```java
   public interface AuthenticationInitContext {
       <T> Optional<T> getService(Class<T> serviceClass);
       <T> Optional<T> getServiceByName(Class<T> serviceClass, String name);
   }
   ```
   
   This solution could be used to pass the Netty event loop, DNS resolver and 
Timer to be shared in the AuthenticationOAuth2 implementation.
   
   ### Alternatives
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [x] I'm willing to submit a PR!


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