temporal
temporal copied to clipboard
[Proposal] New way to write workflow using Temporal
Background
The main problem of this technology is that it requires developers to write code to be replayable. This is against the existing pattern of human programming. Most people don't know their code must be replayable. On the other hand, software must be soft. We have to change code all the time for business changes and new requirements. These two factors together have made things extremely difficult for engineers to use Temporal.
Proposal
Instead of writing the Temporal workflow, we let users write workflow in code by defining a set of WorkflowState. Each WorkflowState defines two things: requestPrecondition and decideNextStates requestPrecondition will request for signals, timers, activity, etc When all/any precondition is met, the decideNextStates is invoked to get the next states to jump into.
To make this idea work, we build one Temporal workflow for everyone so that they don't need to write their Temporal workflow. This workflow will call requestPrecondition and decideNextStates using Temporal activities, so that those user workflow code is always replay safe.
In another way to think about it, this is a Codable version of StepFunctions which is built on top of Temporal.
It preserves all most the full power of Temporal like
- Reset workflow
- Search Attributes
- Writing unit tests for workflow code(which is super hard for StepFunctions)
- etc
And there is no need to worry about non-deterministic errors.
Limitation
- We may lose some readability of the workflow code
- We will lose some flexibility of mutating internal workflow states compared to native Temporal workflow code.
hi @longquanzheng , i totally agree this proposal. Is any progress now?
@ccl0326 yeah I have started the project https://docs.google.com/document/d/1BpJuHf67ibaOWmN_uWw_pbrBVyb6U1PILXyzohxA5Ms/edit
@ccl0326
Some updates Here is the slides of a comparison
A design doc.
We have implemented the first version with Temporal: https://github.com/cadence-oss/iwf
And a Java SDK: It could be easily extended to support any other languages as the API schema is very lightweight
the project is now moved to IndeedEng: https://github.com/indeedeng/iwf and just released the first version