Binds a new durable service / virtual object / workflow.
see restate.service, restate.object, and restate.workflow for more details.
Returns an http2 server handler. See listen 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:
Optional
port: 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 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 either be served either as HTTP2 server, using the methods listen or http2Handler, or as Lambda, using the method lambdaHandler.
Example
A typical endpoint served as HTTP server would look like this:
Example
A typical endpoint served as AWS Lambda would look like this: