Package dev.restate.sdk.http.vertx
Class RestateHttpEndpointBuilder
java.lang.Object
dev.restate.sdk.http.vertx.RestateHttpEndpointBuilder
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 Summary
Modifier and TypeMethodDescriptionbind
(ServiceDefinition<?> serviceDefinition) Add a Restate service to the endpoint.bind
(ServiceDefinition<O> serviceDefinition, O options) Add a Restate service to the endpoint, setting the options.Add a Restate service to the endpoint.io.vertx.core.http.HttpServer
build()
Build theHttpServer
serving the Restate service endpoint.int
Build and listen on the port specified by the environment variablePORT
, or alternatively on the default9080
port.int
buildAndListen
(int port) Build and listen on the specified port.static RestateHttpEndpointBuilder
builder()
Create a new builder.static RestateHttpEndpointBuilder
builder
(io.vertx.core.Vertx vertx) Create a new builder.withOpenTelemetry
(io.opentelemetry.api.OpenTelemetry openTelemetry) Set theOpenTelemetry
implementation for tracing and metrics.withOptions
(io.vertx.core.http.HttpServerOptions options) Add customHttpServerOptions
to the server used by the endpoint.withRequestIdentityVerifier
(RequestIdentityVerifier requestIdentityVerifier) Set the request identity verifier for this endpoint.
-
Method Details
-
builder
Create a new builder. -
builder
Create a new builder. -
withOptions
Add customHttpServerOptions
to the server used by the endpoint. -
bind
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
usingbind(ServiceDefinition)
. -
bind
Add a Restate service to the endpoint.To set the options, use
bind(ServiceDefinition, Object)
. -
bind
Add a Restate service to the endpoint, setting the options. -
withOpenTelemetry
public RestateHttpEndpointBuilder withOpenTelemetry(io.opentelemetry.api.OpenTelemetry openTelemetry) Set theOpenTelemetry
implementation for tracing and metrics.- See Also:
-
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
. -
enablePreviewContext
-
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 variablePORT
, or alternatively on the default9080
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 theHttpServer
serving the Restate service endpoint.
-