xuesong172500 opened a new issue #6698: Pulsar function to instantiate 
URL: https://github.com/apache/pulsar/issues/6698
 
 
   **Is your feature request related to a problem? Please describe.**
   When instantiating the function implementation class, the function 
implementation class's constructor is instantiated by using the 
functions-worker runtime classloader. In the function implementation class's 
constructor, getting the configuration file in the classpath only reads the 
configuration file in Java-instance.jar, and then the function that executes 
the process function has been switched to the function instance's classloader, 
so in process function, you can read the configuration file under classpath in 
the project jar of function application.
   But I want to initialize the members of the function implementation class 
before executing the process function, such as creating a database connection 
and other operations, which cannot be operated.
   
   **Describe the solution you'd like**
   Modify the source code of Function.java and JavaInstanceRunnable.java, add a 
prepare interface in function.java, switch classloader after instantiating 
function at runtime, call the prepare interface first, pass the parameters of 
the command submitted during create function into the prepare interface with 
context, perform initialization operation in the prepare interface, and then 
call the process interface to consume messages.
   
   public interface Function<I, O> {
   
       void prepare(Context context) throws Exception;
   
       /**
        * Process the input.
        *
        * @return the output
        */
       O process(I input, Context context) throws Exception;
   }
   
   **Describe alternatives you've considered**
   A clear and concise description of any alternative solutions or features 
you've considered.
   
   **Additional context**
   Add any other context or screenshots about the feature request here.
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to