Resonate v0.6.0
Release Notes - Version 0.6.0
Overview
The upcoming version of the Resonate SDK significantly changes its architecture and could impact how Resonate is used.
The new Resonate SDK architecture simplifies our codebase while preserving the core functionality of durable promises. By introducing the InvocationHandle and leveraging standard JS Promises, we've addressed the complexities that arose from our previous design.
This new approach offers:
- Clearer control flow
- Explicit durability guarantees
- Simpler implementation
We encourage developers to explore the new SDK and leverage these improved patterns in their applications. Your feedback and innovative use cases will be crucial as we continue to evolve Resonate. Please reach out in the Resonate Community Slack with any questions you might have about this update.
While we still provide most of the same api surface as before this release, like the Context.run
function and Resonate.promises
Object, users should consider this version a breaking change from v0.5.5
New Features
With the new architecture we introduce the concept of an InvocationHandle
. The InvocationHandle holds the resultPromise
, which is where we put the result of the user function when resolving the promise created by it. The result Promise is created when invokeLocal
is called. invokeLocal
uses an async thunk to do the whole process of executing the user code with the proper retries, resolving or rejecting the durable promise, handling all the different kinds of errors, and finally rejecting or resolving the result Promise held by the InvocationHandle. This pattern is mostly enabled by the good support of lexical closures in JS.
Usage of the invocationHandle looks like:
resonate.register('foo', async (ctx: Context) => {
const handle = await ctx.invokeLocal(async (ctx: Context) => {
await setTimeout(1000)
console.log("World")
}, options({retryPolicy: never()}))
console.log("Hello")
let durablePromise = resonate.store.promises.get(handle.invocationId);
console.log(durablePromise.state) // prints: PENDING
await handle.result();
durablePromise = resonate.store.promises.get(handle.invocationId);
console.log(durablePromise.state) // prints: RESOLVED
})
const topHandle = await resonate.invokeLocal("foo", "foo.0")
await topHandle.result()
Bug Fixes
- A bug where new DurablePromises could be created on retries has been fixed.
What's Changed
- Rename some options to improve clarity and intent of them by @avillega in #131
- Update package-lock.json by @avillega in #134
- Change resonate architecture to use Invocation Handles by @avillega in #133
Full Changelog: v0.5.5...v0.6.0