Skip to main content

Serving

Restate services can run in two ways: as an HTTP endpoint or as AWS Lambda functions.

Creating an HTTP endpoint


restate
.endpoint()
.bind(myService)
.bind(myVirtualObject)
.listen();

  1. Create the endpoint
  2. Bind one or multiple services to it.
  3. Listen on the specified port (default 9080) for connections and requests.
Customizing the HTTP2 server

If you need to manually control or customize the HTTP2 server, you can call http2Handler() instead of listen(), and then use it to manually instantiate the HTTP server:


const http2Handler = restate
.endpoint()
.bind(myService)
.bind(myVirtualObject)
.http2Handler()
const httpServer = http2.createServer(http2Handler);
httpServer.listen();

Creating a Lambda handler

To register your service as a Lambda function, change the endpoint into a Lambda handler:


export const handler = restate
.endpoint()
.bind(myService)
.bind(myVirtualObject)
.lambdaHandler();

Have a look at the deployment section for guidance on how to deploy your services on AWS Lambda.

Run on Lambda without handler changes

The implementation of your services and handlers remains the same for both deployment options.