# Flow Controllers

RELE.AI's flow controllers describe the operation's execution order. Out of the box, RELE.AI provides two components to control RELE.AI's flow: Switch Case and Iterators

# Switch Case

Attribute: switch_condition

The switch case operation allows you to create a "junction" in the data processing of RELE.AI based on a given condition and set of optional results.

NOTE

Check the operation definition to see the full layout of the operation configuration

# switch conditions are a simple operation
# that points to a predefined, internal application
type: Operation

# define the pointers to the
# internal app & app action
selector:
    app: core
    app_action: switch_condition

# next operation fallback - if none of the cases matched
next:
  selector:
    - type: operation
      data:
        workflow: example-workflow
        next: process-user-c

# define the switch condition payload
payload:
    # describe the switch case condition
    # in this example we will match
    # to a set of user ids
    condition:
        type: struct
        data: User.Id

    # result 1 for user id - a
    case_1:
        type: raw
        data: a
        match_operation: ==
        next:
            selector:
                - type: operation
                data:
                    workflow: example-workflow
                    next: process-user-a

    # result 2 for user id - b
    case_2:
        type: raw
        data: b
        match_operation: ==
        next:
            selector:
                - type: operation
                data:
                    workflow: example-workflow
                    next: process-user-b

# Special Case Attributes

Attribute Name Type Description
match_operation string

One of:

  • ==
  • !=
  • <
  • >
  • <=
  • >=
  • in
Will match using the operation between the case.data to the condition.data

next Next Pointer to the next operation

# Iterator

Attribute: loop

The iterator operation runs a specific operation until a condition is met. It takes inspiration from a while loop control flow statement.

The iterator operation updates a set of internal variables that are updated and incremented every time the operation is executed. Usually, an iterator will be followed by a switch case that verifies a given condition to set an appropriate breakpoint. Then, the loop itself is defined by the pointers of the following operations.

NOTE

Check the operation definition to see the full layout of the operation configuration

# iterators are a simple operation
# that points to a predefined, internal application
type: Operation

# define the pointers to the
# internal app & app action
selector:
    app: core
    app_action: loop

# define the iterator payload
payload:
    # sets the loop key name
    field:
        data: loop_key_name
        type: raw

    # sets the loop initial index
    start_index:
        data: 0
        type: raw