Class RuntimeServer

java.lang.Object
ai.singlr.runtime.RuntimeServer
All Implemented Interfaces:
AutoCloseable

public final class RuntimeServer extends Object implements AutoCloseable
Programmatic Helidon SE WebServer wrapping an AgentHttpService. Designed for embedding in a service main, or in tests that want a real HTTP endpoint on a random port.

Typical use:

try (var server = RuntimeServer.builder()
    .withRegistry(SessionRegistry.inMemory())
    .withOptionsFactory(sessionId -> SessionOptions.newBuilder()
        .withModel(myModel).withSessionId(sessionId).build())
    .withPort(0)             // random
    .build()) {
  var port = server.port();
  // … drive over HTTP …
}

Thread-safety

The wrapped WebServer is thread-safe. close() is idempotent.
  • Method Details

    • builder

      public static RuntimeServer.Builder builder()
      Start building a server.
      Returns:
      a fresh builder
    • port

      public int port()
      The port the server is bound to. Useful when constructed with port 0 (auto-assigned).
      Returns:
      the bound port
    • registry

      The registry of sessions the server is fronting.
      Returns:
      non-null registry
    • close

      public void close()
      Stop the server and close every registered session. Idempotent.
      Specified by:
      close in interface AutoCloseable