Binds a new durable service / virtual object / workflow.
see restate.service, restate.object, and restate.workflow for more details.
Set default service options that will be used by all services bind to this endpoint.
Options can be overridden on each service/handler.
Returns a combined request handler that auto-detects HTTP/1 vs HTTP/2 requests and dispatches to the appropriate internal handler.
By default (when bidirectional is omitted), HTTP/2+ requests use
bidirectional streaming (BIDI_STREAM) and HTTP/1 requests use
request-response mode (REQUEST_RESPONSE).
Set bidirectional: true to force BIDI_STREAM for all requests,
or bidirectional: false to force REQUEST_RESPONSE for all requests.
This is useful with http2.createSecureServer({ allowHTTP1: true }), where
the same server handles both HTTP/1.1 and HTTP/2 connections.
Optionaloptions: { bidirectional?: boolean }Returns an http1 server handler.
By default, this handler operates in request-response protocol mode (REQUEST_RESPONSE),
which buffers the full request before sending the response. This is the safest mode
for HTTP/1.1 and works across all environments and proxies.
Set bidirectional: true to enable bidirectional streaming (BIDI_STREAM) for
HTTP/1.1 servers that support it. Note that some proxies and clients may not
handle HTTP/1.1 bidirectional streaming correctly.
Optionaloptions: { bidirectional?: boolean }Returns an http2 server handler.
By default, this handler uses bidirectional streaming (BIDI_STREAM).
Set bidirectional: false to use request-response mode (REQUEST_RESPONSE).
See RestateEndpoint.listen for more details.
Optionaloptions: { bidirectional?: boolean }ExperimentalProvider for the codec to use for journal values. One codec will be instantiated globally for this endpoint. Check JournalValueCodec for more details
Serve this Restate Endpoint as HTTP2 server, listening to the given port.
If the port is undefined, this method will use the port set in the PORT
environment variable. If that variable is undefined as well, the method will
default to port 9080.
The returned promise resolves with the bound port when the server starts listening, or rejects with a failure otherwise.
This method is a shorthand for:
Optionalport: numberThe port to listen at. May be undefined (see above).
a Promise that resolves with the bound port, or rejects with a failure otherwise.
const httpServer = http2.createServer(endpoint.http2Handler());
httpServer.listen(port);
If you need to manually control the server lifecycle, we suggest to manually instantiate the http2 server and use RestateEndpoint.http2Handler.
Replace the default console-based LoggerTransport
Using console:
restate.setLogger((meta, message, ...o) => {console.log(`${meta.level}: `, message, ...o)})
Provide a list of v1 request identity public keys eg publickeyv1_2G8dCQhArfvGpzPw5Vx2ALciR4xCLHfS5YaT93XjNxX9 to validate
incoming requests against, limiting requests to Restate clusters with the corresponding private keys. This public key format is
logged by the Restate process at startup if a request identity private key is provided.
If this function is called, all incoming requests irrelevant of endpoint type will be expected to have
x-restate-signature-scheme: v1 and x-restate-jwt-v1: <valid jwt signed with one of these keys>. If not called,
RestateEndpoint encapsulates all the Restate services served by this endpoint.
A RestateEndpoint can be served as:
For Lambda, check LambdaEndpoint
Example
A typical endpoint served as HTTP/2 server:
Example
Using the HTTP/1.1 handler with your own server:
Example
Using the combined handler with an HTTP/2 server that also accepts HTTP/1.1: