Skip to content

Martini Services Fork Step

Overview

The Fork Step is a control flow mechanism designed for conditional execution of service steps. It functions similarly to conditional branching structures found in traditional programming languages, such as the switch statement in Java.

Behavior

When a Fork Step is activated, it evaluates a specified expression to determine the execution path. The outcome of this expression is used to select among various child steps, each labeled to correspond with potential expression results. The operational flow is as follows:

  1. Evaluate Expression: The Fork Step begins by evaluating its 'Expression' property.

  2. Select Child Step:

    • If the expression returns a value, the Fork Step searches for a child step labeled with the same value and executes it.
    • If the expression yields null, the child step labeled $null is executed.
    • In the absence of a matching label, the Fork Step looks for a child labeled $else.
    • If no matches are found (including $else), no child steps are executed.
  3. Execution Flow: The selected child step is executed exclusively, akin to how a case block operates in a Java switch statement, including an implicit break at the end of each case.

Considerations

  • Label Matching: Ensure that labels are uniquely and accurately defined to match potential expression outcomes.
  • Default Handling: It's advisable to include a $else labeled child as a catch-all for unanticipated expression results.
  • Performance: Optimizing the expression and organizing child steps effectively can enhance the performance and readability of the Fork Step.