You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/04/09 06:54:45 UTC

[GitHub] [pulsar] xuesong172500 opened a new issue #6698: Pulsar function to instantiate

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:
users@infra.apache.org


With regards,
Apache Git Services