Questions, in detail
Where the steps are, what runs as your own code, and how the flow stays durable around it.
Is Cube Root part of Cube (cube.dev)?
No. Cube Root (cube-root.com) is a durable execution engine: plain Java, TypeScript and Python, made durable by its compiler. It is not related to Cube (cube.dev), the analytics semantic layer.
Does the compiler turn every line of my code into a durable step?
No. A step ends where the code waits: at a call to a service, a person or a timer. The lines between two calls are your own code: they run as written, in memory, and are not saved line by line.
What happens to my local variables and objects between two calls?
The compiler takes care of it. It decides which code is native and which is orchestration: native code runs in your own runtime, as written, with the objects it holds. A flow resumes after a crash, or on another machine, with its values as they were. You write nothing for it.
Can a flow use async and await?
Yes, as you already write them, though a flow does not need them. Every call in a flow already waits: the server holds the conversation while a service, a person or a timer answers, for milliseconds or for days, and no thread waits for it. Calls that do not need each other already run together: the compiler sees it from the data.
So each async form is read as the plain line it means, and gives the same graph. In TypeScript: an async invoke, await on a call, Promise.all. In Python: async def invoke, await, asyncio.gather. A join over a list is a parallel loop.
A form that would change the meaning is refused by name, with the line: .then, new Promise, Promise.race, or a call that is never awaited. The services it calls are ordinary code and use async as they like.
Can I call third-party libraries?
Yes, the whole language and its libraries. What is still in use after a service call is kept as a row, so it is serializable; a value that cannot be, such as an open connection, is not carried across the call.
How can determinism be checked at compile time if my code calls libraries?
Cube Root does not replay your code. A finished step's values are kept as rows, and a resumed flow continues from them: nothing is run again to rebuild them. So determinism is a question about the flow itself, and the compiler checks the flow once, when it is compiled.
Why does the compiler refuse some code?
A flow that survives a crash may resume on another machine. What lives only on the first machine, such as an open connection, cannot come along. Code that leans on it works on one machine and passes every test; it fails on the day a machine dies. A compiler for durable execution moves that day forward, to the day you compile.
What does a flow that mixes durable calls and local code look like?
An order. Each line, and how it runs:
| The flow, in Java | How it runs |
|---|---|
| Risk r = risk.invoke(o); | a step |
| Stock s = stock.invoke(o); | a step, beside the one above: it does not need r |
| String note = String.format("risk %s, %d in stock", r.level(), s.count()); | your own code, in memory, once both answers are in |
| String done; | a plain line |
| try { | what the try finishes is undone if it fails |
| String paid = charge.invoke(o); | a step |
| String sent = ship.invoke(o); | a step, after the charge |
| done = paid + ", " + sent; | a plain line |
| } catch (Exception e) { | before it runs, the charge is undone |
| done = "not shipped, the charge undone"; | a plain line |
| } | |
| return note + "; " + done; | the answer |
Write keep: on the try to keep what it finished instead of undoing it.
cube-root.com · Home · Contact