Interface ServerPlugin

All Superinterfaces:
Plugin
All Known Implementing Classes:
JettyPlugin, SpringPlugin

public interface ServerPlugin extends Plugin
ServerPlugin is an extended Plugin interface for plugins that provide HTTP server functionality.

This interface adds lifecycle methods for starting and stopping servers. The start() method blocks until the server is stopped, similar to Express's app.listen() in JavaScript.

Example usage:


 JettyPlugin jetty = new JettyPlugin(JettyPluginOptions.builder().port(8080).build());
 
 Genkit genkit = Genkit.builder().plugin(jetty).build();
 
 // Define your flows here...
 
 // Start the server and block - this replaces Thread.currentThread().join()
 jetty.start();
 
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the port the server is listening on.
    boolean
    Returns true if the server is currently running.
    void
    Starts the HTTP server and blocks until it is stopped.
    void
    Stops the HTTP server.

    Methods inherited from interface com.google.genkit.core.Plugin

    getName, init, init
  • Method Details

    • start

      void start() throws Exception
      Starts the HTTP server and blocks until it is stopped.

      This is the recommended way to start a server in a main() method. Similar to Express's app.listen() in JavaScript, this method will keep your application running until the server is explicitly stopped.

      Throws:
      Exception - if the server cannot be started or if interrupted while waiting
    • stop

      void stop() throws Exception
      Stops the HTTP server.
      Throws:
      Exception - if the server cannot be stopped
    • getPort

      int getPort()
      Returns the port the server is listening on.
      Returns:
      the server port
    • isRunning

      boolean isRunning()
      Returns true if the server is currently running.
      Returns:
      true if running, false otherwise