ke4roh / vertx-engine

An execution engine for processing things, based on vertx
Apache License 2.0
1 stars 2 forks source link

Add a "when" parameter to AbstractTask like Ansible's #37

Closed ke4roh closed 5 years ago

ke4roh commented 5 years ago

Add a "when" parameter that takes a string which, once interpreted, yields a boolean. It should be tacitly run through Jinja, too, without the squigglies (or with them, if they're provided).

When this expression evaluates false, throw StepDependencyNotMetException. Perform this expression evaluation in an overridable method on AbstractTask.

When all remaining pending steps for a section have thrown the exception, the section is complete and the steps need not wait further.

LightGuard commented 5 years ago

We're basically going back to the ready check idea?

ke4roh commented 5 years ago

I can also see the parallel. They are different motivations with the same outcome. Steps cannot execute when their input is missing, true, and neither should they execute when other pre-conditions aren't met. This is explicitly adding a precondition for step execution so that there is a standardized way in implementations of AbstractStep to gate by boolean expressions.

ke4roh commented 5 years ago

To get the "when" parameter and evaluate it against the environment at runtime, we can save an unmodifiable Map of the config in the call to AbstractStep.init(...) and inject that map into the environment with a new key in AbstractStep.getEnvironment(uuid)