Package com.google.genkit.core
Interface ServerPlugin
- All Superinterfaces:
Plugin
- All Known Implementing Classes:
JettyPlugin,SpringPlugin
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
-
Method Details
-
start
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
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
-