-
Notifications
You must be signed in to change notification settings - Fork 567
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
Load arbitrary interceptors in the gateway #7839
Conversation
This is a pretty big PR, honestly (though most of it is test code 😄 - and I'm still missing some tests!). I'm happy to try and split it, but I wasn't sure where would be best. I tried to still split by commits though, so you should be able to review each sort of separately. It's not completely finished, but I figured it might be good to have a look at it already. As you can see from the test NOTE: it seems blocking is fine in the listeners, so says their docs, so we might want to encourage that in the future. To tackle asynchronous issues and the TCL, I added a |
889528b
to
fc57205
Compare
fc57205
to
af766be
Compare
af766be
to
6a47ff1
Compare
Updates ReflectUtil#newInstance to avoid usage of deprecated APIs.
Adds a call method which also ensures the TCL is correctly set.
Use update ReflectUtil#newInstance instead of custom implementation. Also updates test to make test exporter classes visible to ReflectUtil.
Adds user configuration for arbitrary interceptors as part of the general gateway configuration. Interceptors are specified as a list of interceptor configuration, in the order in which they will be called by the server.
Loads arbitrary interceptors as part of the gateway startup, and wraps the gateway service with them in a chain. Interceptors can be loaded from external JARs, and will be loaded with isolated class loaders to avoid dependency collisions. Each interceptor is decorated with a special internal interceptor which forwards the intercept call, ensuring that for that call, the thread context class loader is correctly set. An executor is provided in the context, accessible via InterceptorUtil, which lets users use asynchronous code and pipe it back to it to ensure their call sets the right thread context class loader.
Adds an integration test for interceptors loaded from the class path, with a dummy interceptor which will deny DEPLOYMENT calls with a specific error code and message.
609cfa7
to
6457f53
Compare
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.
looks good to me, feel free to squash and merge
bors merge |
Build succeeded: |
Description
This PR allows loading arbitrary interceptors in the gateway, which will wrap every call and allow for users to specify custom logic before and after each call.
Interceptors are specified in the configuration of the gateway under
zeebe.gateway.interceptors
, orzeebe.broker.gateway.interceptors
. They're mapped as a list, and will be called in the order in which they are defined in the configuration. So item 0 will be called first, then item 1, etc., with the actual service at the end. NOTE: the monitoring interceptor, if enabled, remains the top level one and will wrap all further interceptors.Interceptors can be loaded from the class path, or via an external JAR by specifying their
jarPath
configuration property. If so, they will have an isolated class loader, which will ensure that, should they bundle dependencies that would collide with Zeebe's, there will be no collision and each side (the interceptor and the gateway) will use the right dependency.Related issues
closes #7755
Definition of Done
Not all items need to be done depending on the issue and the pull request.
Code changes:
backport stable/0.25
) to the PR, in case that fails you need to create backports manually.Testing:
Documentation: