TaskFlow/Best practices
Summary
Why
Since taskflow creates a path toward stable, resumable, and trackable workflows it is helpful to have a small set of recommended best practices to make sure you as a user of taskflow (the library) maximize the benefit you receive from using taskflow. Certain common patterns and best practices will be listed below (with examples) to show the what, why and how so that you can maximize your taskflow experience and minimize the pain associated with understanding some of the taskflow key primitives. This list will likely continue growing as new usages of taskflow emerge (and new features are introduced into taskflow), please feel free to add any of your own below.
Top 5
- Create tasks that do one thing well; if that task has side-effects undo those side-effects in the
revert
method. - Clearly define what a task provides so that future (potentially not yet created) tasks can depend on those outputs.
- Clearly define what a task requires so that taskflow
engine/s
can deduce the correct order to run your tasks in. - Be very careful about RPC boundaries (especially when the workflow spans this boundary) and choose how you deal with this in a careful manner.
- Always associate a version with your tasks so that one software upgrades the partially completed tasks can be migrated & resumed.