@resonatehq/aws
v0.2.0
Published
Resonate FaaS handler for AWS Lambda Functions (TypeScript)
Readme
@resonatehq/aws
@resonatehq/aws is the official binding to run Resonate durable execution workers on AWS Lambda. Write long-running, stateful applications on short-lived, stateless serverless infrastructure.
Installation
npm install @resonatehq/awsHow it works
When a Durable Function suspends (e.g. on yield* context.rpc() or context.sleep()), the Lambda function terminates. When the Durable Promise completes, the Resonate Server resumes the function by invoking Lambda again — no long-running process required.
Usage
Register your functions and export the HTTP handler from your Lambda entry point:
import { Resonate } from "@resonatehq/aws";
import type { Context } from "@resonatehq/aws";
const resonate = new Resonate();
resonate.register("countdown", function* countdown(ctx: Context, n: number): Generator {
if (n <= 0) {
console.log("done");
return;
}
console.log(n);
yield* ctx.sleep(1000);
yield* ctx.rpc(countdown, n - 1);
});
// Export as an AWS Lambda Function URL handler
export const handler = resonate.httpHandler();Deploy this as an AWS Lambda Function URL. The Resonate Server will call your handler to invoke and resume durable functions.
See the AWS Lambda documentation to learn how to develop and deploy Lambda functions.
Examples
Documentation
Full documentation: docs.resonatehq.io
