Class Invoker


  • public class Invoker
    extends Object
    Java server that runs the user's code (a jar file) on HTTP request and an HTTP response is sent once the user's function is completed. The server accepts HTTP requests at '/' for executing the user's function, handles all HTTP methods.

    This class requires the following environment variables:

    • PORT - defines the port on which this server listens to HTTP requests.
    • FUNCTION_TARGET - defines the name of the class defining the function.
    • FUNCTION_SIGNATURE_TYPE - determines whether the loaded code defines an HTTP or event function.
    • Method Detail

      • startServer

        public void startServer()
                         throws Exception
        This will start the server and wait (join) for function calls. To start the server inside a unit or integration test, use startTestServer() instead.
        Throws:
        Exception
        See Also:
        stopServer()
      • startTestServer

        public void startTestServer()
                             throws Exception
        This will start the server and return.

        This method is designed to be used for unit or integration testing only. For other use cases use startServer().

        Inside a test a typical usage will be:

        
         // Create an invoker
         Invoker invoker = new Invoker(
             8081,
             "org.example.MyHttpFunction",
             "http",
             Thread.currentThread().getContextClassLoader());
        
         // Start the test server
         invoker.startTestServer();
        
         // Test the function
        
         // Stop the test server
         invoker.stopServer();
         
        Throws:
        Exception
        See Also:
        stopServer()