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(dev.restate.sdk.common.syscalls.ServiceDefinition<?> serviceDefinition) Add a Restate service to the endpoint.bind(dev.restate.sdk.common.syscalls.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.HttpServerbuild()Build theHttpServerserving the Restate service endpoint.intBuild and listen on the port specified by the environment variablePORT, or alternatively on the default9080port.intbuildAndListen(int port) Build and listen on the specified port.static RestateHttpEndpointBuilderbuilder()Create a new builder.static RestateHttpEndpointBuilderbuilder(io.vertx.core.Vertx vertx) Create a new builder.withOpenTelemetry(io.opentelemetry.api.OpenTelemetry openTelemetry) Set theOpenTelemetryimplementation for tracing and metrics.withOptions(io.vertx.core.http.HttpServerOptions options) Add customHttpServerOptionsto the server used by the endpoint.withRequestIdentityVerifier(dev.restate.sdk.auth.RequestIdentityVerifier requestIdentityVerifier) Set the request identity verifier for this endpoint.
-
Method Details
-
builder
Create a new builder. -
builder
Create a new builder. -
withOptions
Add customHttpServerOptionsto 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
ServiceDefinitionusingbind(ServiceDefinition). -
bind
public RestateHttpEndpointBuilder bind(dev.restate.sdk.common.syscalls.ServiceDefinition<?> serviceDefinition) Add a Restate service to the endpoint.To set the options, use
bind(ServiceDefinition, Object). -
bind
public <O> RestateHttpEndpointBuilder bind(dev.restate.sdk.common.syscalls.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 theOpenTelemetryimplementation for tracing and metrics.- See Also:
-
OpenTelemetry
-
withRequestIdentityVerifier
public RestateHttpEndpointBuilder withRequestIdentityVerifier(dev.restate.sdk.auth.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 default9080port.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 theHttpServerserving the Restate service endpoint.
-