Class RestateHttpEndpointBuilder

java.lang.Object
dev.restate.sdk.http.vertx.RestateHttpEndpointBuilder

public class RestateHttpEndpointBuilder extends Object
Endpoint builder for a Restate HTTP Endpoint using Vert.x, to serve Restate services.

This endpoint supports the Restate HTTP/2 Streaming component Protocol.

Example usage:

 public static void main(String[] args) {
   RestateHttpEndpointBuilder.builder()
           .bind(new Counter())
           .buildAndListen();
 }
 
  • Method Details

    • builder

      public static RestateHttpEndpointBuilder builder()
      Create a new builder.
    • builder

      public static RestateHttpEndpointBuilder builder(io.vertx.core.Vertx vertx)
      Create a new builder.
    • withOptions

      public RestateHttpEndpointBuilder withOptions(io.vertx.core.http.HttpServerOptions options)
      Add custom HttpServerOptions to the server used by the endpoint.
    • bind

      public RestateHttpEndpointBuilder bind(Object service)
      Add a Restate service to the endpoint. This will automatically discover the generated factory based on the class name.

      You can also manually instantiate the ServiceDefinition using bind(ServiceDefinition).

    • bind

      public RestateHttpEndpointBuilder bind(ServiceDefinition<?> serviceDefinition)
      Add a Restate service to the endpoint.

      To set the options, use bind(ServiceDefinition, Object).

    • bind

      public <O> RestateHttpEndpointBuilder bind(ServiceDefinition<O> serviceDefinition, O options)
      Add a Restate service to the endpoint, setting the options.
    • withOpenTelemetry

      public RestateHttpEndpointBuilder withOpenTelemetry(io.opentelemetry.api.OpenTelemetry openTelemetry)
      Set the OpenTelemetry implementation for tracing and metrics.
      See Also:
      • OpenTelemetry
    • withRequestIdentityVerifier

      public RestateHttpEndpointBuilder withRequestIdentityVerifier(RequestIdentityVerifier requestIdentityVerifier)
      Set the request identity verifier for this endpoint.

      For the Restate implementation to use with Restate Cloud, check the module sdk-request-identity.

    • buildAndListen

      public int buildAndListen(int port)
      Build and listen on the specified port.

      NOTE: this method will block for opening the socket and reserving the port. If you need a non-blocking variant, manually build() the server and start listening it.

      Returns:
      The listening port
    • buildAndListen

      public int buildAndListen()
      Build and listen on the port specified by the environment variable PORT, or alternatively on the default 9080 port.

      NOTE: this method will block for opening the socket and reserving the port. If you need a non-blocking variant, manually build() the server and start listening it.

      Returns:
      The listening port
    • build

      public io.vertx.core.http.HttpServer build()
      Build the HttpServer serving the Restate service endpoint.