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 2019/06/03 21:57:42 UTC

[GitHub] [pulsar] jerrypeng opened a new pull request #4453: Function localrun improved

jerrypeng opened a new pull request #4453: Function localrun improved
URL: https://github.com/apache/pulsar/pull/4453
 
 
   ### Motivation
   
   User's have complained that is hard to debug Pulsar functions.  There is not way to use an debugger or IDE to step through a function to debug.
   
   While functions currently support running via local run, there is no trivial way to hook it up to an IDE to debug.
   
   Also the localrunner spawns of functions in separate processes.  While this is only for Python functions, it is kind inconvenient for java functions.
   
   ### Modifications
   
   I heavily modified LocalRunner to be able to be called programmatically and start a java function/source/sink as a thread.  Users can then put break points in their function code to debug.
   
   Example of how to start a function instance programatically:
   
   ```
   public class TestFunction implements Function<String, String> {
   
       @Override
       public String process(String s, Context context) throws Exception {
           System.out.println("s: " + s);
           return s + "!";
       }
   
   
       public static void main(String[] args) throws Exception {
           Configurator.setRootLevel(Level.INFO);
   
   
           FunctionConfig functionConfig = createFunctionConfig("public", "default", "foo", "input", "output");
           LocalRunner localRunner = LocalRunner.builder().functionConfig(functionConfig).brokerServiceUrl("pulsar://127.0.0.1:6650").build();
   
           localRunner.start(false);
   
       }
   ```

----------------------------------------------------------------
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