Skip to content

resonatehq/resonate-faas-gcp-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@resonatehq/gcp

@resonatehq/gcp is the official binding to run Resonate durable execution workers on Google Cloud Functions. Write long-running, stateful applications on short-lived, stateless serverless infrastructure.

Installation

npm install @resonatehq/gcp

How it works

When a Durable Function suspends (e.g. on yield* context.rpc() or context.sleep()), the Cloud Function terminates. When the Durable Promise completes, the Resonate Server resumes the function by invoking it again — no long-running process required.

Resonate on Serverless

Usage

Register your functions and export the HTTP handler from your Cloud Function entry point:

import { Resonate } from "@resonatehq/gcp";
import type { Context } from "@resonatehq/gcp";

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 a Google Cloud Functions HTTP handler
export const handler = resonate.httpHandler();

Deploy this as a Google Cloud Function with an HTTP trigger. The Resonate Server will call your handler to invoke and resume durable functions.

See the Google Cloud Functions documentation to learn how to develop and deploy Cloud Functions.

Examples

Documentation

Full documentation: docs.resonatehq.io

About

TypeScript FaaS adapter for Resonate on Google Cloud Functions

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors