Use separate classloader loading user functions JARs #4277
Labels
area/function
type/enhancement
The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Motivation
Currently, we use are using a custom shaded java-instance.jar to run functions.
This creates a couple issues:
Proposal
A more elegant solution is instead of using a uber clustom shaded JAR to run functions, we can use separate classloaders to load function framework code and user code.
To be more precise, we will have one "root" classloader that will load pulsar-client-api and pulsar-function-api JARs since they contain interfaces that the function framework code needs to communicate/share with the user function code. From this "root" classloader, we will create a child classloader i.e. function framework classloader that will load all the pulsar client impl JARs and function impl JARS. Basically everything under the "lib/" directory. We will create another child classloader from the "root" classloader that will load the user function code.
Since the function code in a separate classloader, users can still use what dependencies of whichever version they choose yet still not conflict with the function framework code.
This eliminates the the need to to have java-instance.jar and users can also call pulsar-client or pulsar-client-admin from within a function.
some sample code to demonstrate this:
The text was updated successfully, but these errors were encountered: