What would you like to be added:
It would be highly beneficial to introduce a fork() static method in FuncDSL that natively accepts branch configurations. Ideally, it would look something like this:
import static io.serverlessworkflow.fluent.func.dsl.FuncDSL.*;
import io.serverlessworkflow.fluent.func.FuncWorkflowBuilder;
// ...
FuncWorkflowBuilder.workflow("parallel-execution-workflow")
.tasks(
// Proposed FuncDSL.fork() syntax
fork("inventory-and-credit-check", branches(
http("checkInventory", h -> h.method("POST").body("").endpoint("http://localhost:8089/inventory-check")),
http("checkCredit", h -> h.method("POST").body("").endpoint("http://localhost:8089/credit-check"))
))
)
.build();
Why is this needed:
Adding a top-level FuncDSL.fork(...) would significantly improve readability and consistency within the fluent DSL.
Implementing this will align parallel execution with the rest of the FuncDSL design patterns, reducing boilerplate and flattening the lambda indentation for developers orchestrating concurrent tasks.
Developer experience to match other high-level constructs like call(), switchWhenOrElse(), or forEach().
Current Workaround:
To achieve parallel execution today, developers must use the verbose nested builder approach:
// ...
FuncWorkflowBuilder.workflow("parallel-execution-workflow")
.tasks(
funcTaskItemListBuilder -> funcTaskItemListBuilder.fork(
funcForkTaskBuilder -> funcForkTaskBuilder.branches(
inner -> {
inner.http("checkInventory",
h -> h.method("POST").body("")
.endpoint("http://localhost:8089/inventory-check"));
inner.http("checkCredit",
h -> h.method("POST").body("")
.endpoint("http://localhost:8089/credit-check"));
}
)
)
)
.build();
Or similarly with branch(...):
// ...
FuncWorkflowBuilder.workflow("parallel-workflow-using-branch")
.tasks(
funcDoTaskBuilder -> funcDoTaskBuilder.fork("checkCreditAndInventoryFork",
funcForkTaskBuilder -> funcForkTaskBuilder
.branch(
post("checkInventory", "", "http://localhost:8089/inventory-check"))
.branch(
call("checkCredit",
post("checkCredit", "", "http://localhost:8089/credit-check")))))
.build();
What would you like to be added:
It would be highly beneficial to introduce a fork() static method in FuncDSL that natively accepts branch configurations. Ideally, it would look something like this:
Why is this needed:
Adding a top-level FuncDSL.fork(...) would significantly improve readability and consistency within the fluent DSL.
Implementing this will align parallel execution with the rest of the FuncDSL design patterns, reducing boilerplate and flattening the lambda indentation for developers orchestrating concurrent tasks.
Developer experience to match other high-level constructs like call(), switchWhenOrElse(), or forEach().
Current Workaround:
To achieve parallel execution today, developers must use the verbose nested builder approach:
Or similarly with
branch(...):