Jump to: navigation, search

TaskFlow/Engines

< TaskFlow
Revision as of 05:52, 14 September 2013 by Harlowja (talk | contribs) (Engine)

Engine

Felipecaparelli Gears 1.png

Engine is what really runs the tasks. It should take flow structure (described by patterns) and use it to decide which task to run and when.

There may be different implementation of engines. Some may be easier to use (like, require no setup) and understand, others might require more complicated setup but provide better scalability. The idea and ideal is that deployers of a service that uses taskflow can select an engine that suites their setup best without modifying code of said service. This allows for starting off using a simpler implementation and scaling out the service that is powered by taskflow as the service grows.

In concept, all engines should implement same interface to make it easy to replace one engine with another, and provide same guaranties on how patterns are interpreted -- for example, if an engine runs a linear flow, the tasks should be run one after another in order.

Possible engines include:

  • Simple -- just takes e.g. linear flow and runs tasks from it one after another -- should be useful for debugging tasks and simple use cases;
  • Threaded -- Runs tasks in separate threads enabling them to run in parallel (even several implementations are possible);
  • Distributed -- loads tasks to celery (or some other external service) that uses tasks dependencies to determine ordering;


Note: Engines might have different capabilities and different configuration but overall the interface should remain the same.

How

Blueprint: https://blueprints.launchpad.net/taskflow/+spec/patterns-and-engines

Storage

Storage is out of scope of the blueprint, but it is still worth to point out its role here.

We already have storage in taskflow -- that's logbook. But it should be emphasized that logbook should become the authoritative, and, preferably, the only source of runtime state information. When task returns result, it should be written directly to logbook. When task or flow state changes in any way, logbook is first to know. Flow should not store task results -- there is logbook for that.

Logbook and a backend are responsible to store the actual data -- these together specify the persistence mechanism (how data is saved and where -- memory, database, whatever), and persistence policy (when data is saved -- every time it changes or at some particular moments or simply never).