-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add broker interceptor for Intercepting all Pulsar command and REST API requests #7143
Add broker interceptor for Intercepting all Pulsar command and REST API requests #7143
Conversation
@codelipenghui thanks for working on something like this. The funny thing is we have developed an "interceptor" framework as well. It covers all the REST endpoints as well. Maybe we can collaborate? |
@jerrypeng do you want to send out the pull request? so we can merge efforts here. |
…or-pulsar with conflicts.
b5d7f64
to
bdea8b8
Compare
Added PR: #7159 |
category = CATEGORY_INTERCEPTORS, | ||
doc = "The directory to locate interceptors" | ||
) | ||
private String interceptorDirectory = "./interceptors"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall looks good to me. I see there are two sets of settings here, one is for listeners
and the other one is for interceptors
? I think we should just rename the listener interfaces to Interceptors. So it is consistent with client-side interceptor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
@@ -450,7 +453,9 @@ public void start() throws PulsarServerException { | |||
|
|||
this.defaultOffloader = createManagedLedgerOffloader( | |||
OffloadPolicies.create(this.getConfiguration().getProperties())); | |||
|
|||
this.brokerInterceptor = BrokerInterceptors.load(config); | |||
brokerService.setInterceptor(getBrokerInterceptor()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should support multiple broker interceptors. Can you add a broker interceptor implementation that wraps a list of interceptors into one interceptor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current implementation is supporting multiple broker interceptors, I added BrokerInterceptors.java also implement BrokerInterceptor interface.
@merlimat put up our version of this. I thought we were going to work together merge both our implementation? |
There are many points that are missing in this implementation. Especially on how to give a proper error to the client when some operation is denied. |
Also, this is exposing various internal classes to the interceptor API. That means that these classes are now becoming part of public API, which is not a good idea since they were not meant to be. |
@merlimat @jerrypeng I think this is to set up the framework so the broker can load interceptors from NAR packages. The interface is very basic and only focuses on intercepting connections. We don't expect this interface to the public at this moment. It is the first step to implement interceptors. We should iterate the interface and add the pull request #7159 that @merlimat sent for intercepting per restful call. Since these two pull requests have different focuses (NAR class loading, connection level interception vs per-rest-call interception) and they can be merged together, I don't see we need to block one pull request for the other pull request. Especially in any case, we need to load the plugin from NAR package just as what we did for other plugins, correct? |
…PI requests. (apache#7143) Add broker interceptor for Intercepting all Pulsar command and REST API requests
…PI requests. (apache#7143) Add broker interceptor for Intercepting all Pulsar command and REST API requests
Motivation
Broker Interceptors
Modifications
Describe the modifications you've done.
Verifying this change
Does this pull request potentially affect one of the following parts:
If
yes
was chosen, please highlight the changesDocumentation