-
Notifications
You must be signed in to change notification settings - Fork 216
defining workflow
A work flow in Easy Flows is represented by the WorkFlow
interface:
public interface WorkFlow extends Work {
}
A workflow is also a work. This what makes workflows composable.
Easy Flows comes with 4 implementations of the WorkFlow
interface:
A conditional flow is defined by 4 artifacts:
- The work to execute first
- A
WorkReportPredicate
for the conditional logic - The work to execute if the predicate is satisfied
- The work to execute if the predicate is not satisfied (optional)
To create a ConditionalFlow
, you can use the ConditionalFlow.Builder
:
ConditionalFlow conditionalFlow = ConditionalFlow.Builder.aNewConditionalFlow()
.named("my conditional flow")
.execute(work1)
.when(WorkReportPredicate.COMPLETED)
.then(work2)
.otherwise(work3)
.build();
A SequentialFlow
, as its name implies, executes a set of work units in sequence. If a work fails, next works in the pipeline will be skipped. To create a SequentialFlow
, you can use the SequentialFlow.Builder
:
SequentialFlow sequentialFlow = SequentialFlow .Builder.aNewSequentialFlow()
..named("execute 'work1', 'work2' and 'work3' in sequence")
.execute(work1)
.then(work2)
.then(work3)
.build();
A parallel flow executes a set of works in parallel. The status of a parallel flow execution is defined as:
-
WorkStatus#COMPLETED
: If all works have successfully completed -
WorkStatus#FAILED
: If one of the works has failed
To create a Parallel Flow
, you can use the ParallelFlow.Builder
:
ParallelFlow parallelFlow = ParallelFlow .Builder.aNewParallelFlow()
.named("execute 'work1', 'work2' and 'work3' in parallel")
.execute(work1, work2, work3)
.build();
RepeatFlow repeatFlow = RepeatFlow .Builder.aNewRepeatFlow()
.named("execute work 3 times")
.repeat(work)
.times(3)
.build();
// or
RepeatFlow repeatFlow = RepeatFlow .Builder.aNewRepeatFlow()
.named("execute work forever!")
.repeat(work)
.until(WorkReportPredicate ALWAYS_TRUE)
.build();
Those are the basic flows you need to know to start creating workflows with Easy Flows. You don't need to learn a complex notation or concepts, just a few natural APIs that are easy to think about.
You can create your own flows by implementing the WorkFlow
interface.
The WorkFlowEngine
works against interfaces, so your implementation should be interoperable with built-in flows without any issue.
-
Introduction
-
User guide
-
Get involved