This quickstart will introduce the Resonate TypeScript SDK in three steps. The sample application is an Express web application using the Resonate SDK to simulate the process of web content summarization:
# Summarize a URL
$ curl -X POST http://localhost:3000/summarize -H "Content-Type: application/json" -d '{"url": "http://example.com"}'
The central function is downloadAndSummarize
. downloadAndSummarize
calls two functions, download
and summarize
. Both download
and summarize
return a hard coded value but introduce a deliberate delay and may throw an exception to mimic real-world behavior:
// Simulates downloading and summarizing web content.
export async function downloadAndSummarize(ctx: Context, url: string) {
// Simulate downloading content. May throw an exception 💣
let content = await ctx.run(download, url);
// Simulate summarizing the downloaded content. May throw an exception 💣
let summary = await ctx.run(summarize, content);
// return summary
return summary;
}
In Step 1, develop your first Distributed Async Await application with the Resonate SDK. This step illustrates features such as transparent retries, rate limits, or tracing, simply through the integration of the Resonate SDK, without the need for any additional infrastructure.
In Step 2, boost your application's reliability by integrating with a Resonate Server, enabling recovery to mitigate failures.
In Step 3, boost your application's scalability by deploying Resonate Workers, enabling fan out and fan in to mitigate demand.