[feat] Authentication implementations such as AuthenticationOAuth2 should support sharing thread pools or DNS cache
Search before reporting
- [x] I searched in the 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.
/**
* 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:
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!
Hi @lhotari, I would like to work on this issue. I plan to start exploring a solution and would greatly appreciate any guidance or context you can provide. Thank you
Hi @lhotari, I would like to work on this issue. I plan to start exploring a solution and would greatly appreciate any guidance or context you can provide. Thank you
@AradhyaSharma31 Thanks for volunteering. This might not be the best way to start contributing to Pulsar, but you can always give it a try. The Pulsar Contributor guide is available at https://pulsar.apache.org/contribute/ with multiple instructions. For example:
- Setting up IDE
- Personal CI to run CI in your own fork
You can join the dev channel on Pulsar Slack to coordinate work. I might not be able to respond immediately, but I usually put effort to help if someone is putting effort to contribute.
Hi @lhotari, I would like to work on this issue. I plan to start exploring a solution and would greatly appreciate any guidance or context you can provide. Thank you
Hi, are you still working on this issue?
Hi @lhotari, I would like to work on this issue. I plan to start exploring a solution and would greatly appreciate any guidance or context you can provide. Thank you
Hi, are you still working on this issue?
@3pacccccc Not at the moment. btw. Please also review the comment in https://github.com/apache/pulsar/pull/24944#issuecomment-3520852664 .
Hi @lhotari, I would like to work on this issue. I plan to start exploring a solution and would greatly appreciate any guidance or context you can provide. Thank you
Hi, are you still working on this issue?
@3pacccccc Not at the moment. btw. Please also review the comment in #24944 (comment) .
@lhotari OK, I see, I'll working on this.
Hi, I’ve completed the work for this issue. I was busy for a while, so I hadn’t pushed it yet.
If it’s still useful, I can open a PR. Let me know if I should proceed or if the current assignee is already on it.
Hi, I’ve completed the work for this issue. I was busy for a while, so I hadn’t pushed it yet. If it’s still useful, I can open a PR. Let me know if I should proceed or if the current assignee is already on it.
@AradhyaSharma31 Sure, please go ahead and open a PR. It's recommended to run tests in your own fork as the first step for larger changes, please see https://pulsar.apache.org/contribute/personal-ci/. Please also check comments at https://github.com/apache/pulsar/pull/24944#issuecomment-3520852664.
@lhotari Thanks for the guidance. After reviewing the changes in #24944 , I see that parts of my implementation conflict with the updated OAuth2 structure. I’ll refactor my solution to align with the new code and then open the PR.
I’ve been running mock tests and Pulsar CI locally when validating changes. If there are additional checks or recommended steps I should follow, please let me know.
I’ve been running mock tests and Pulsar CI locally when validating changes. If there are additional checks or recommended steps I should follow, please let me know.
@AradhyaSharma31 Please follow the instructions in https://pulsar.apache.org/contribute/personal-ci/ to first open a PR in your own fork and run the full Pulsar CI GitHub Actions pipeline there. It's not a very feasible solution to run the full pipeline locally since it requires about 10 hours of compute time to run all tests. You get this for free with GitHub Actions.