Flows

The flows are configured using one or more HCL files. These HCL files define what calls have to perform on execution or rollbacks to be called during a unexpected error.

Introduction

A flow contains a collection of resources which is executed when a endpoint gets triggered. If an error occurs during the execution of the flow are all rollbacks of executed calls called.

flow "todo" {
    resource "query" {
        request "service" "GetTodos" {}
    }
}

Services are defined inside the schema definitions

You could expose flows by defining an endpoint. An endpoint defines the protocol to be used and protocol-specific options.

endpoint "todo" "http" {
    method = "GET"
    endpoint = "/todos"
}

Resources

Requests and rollbacks

A resource inside a flow could contain a request and/or a rollback. Requests are called when a flow is triggered. If any of the defined resources returns an unexpected error the rollbacks of all executed resources executed. Errors returned by rollbacks are ignored.

resource "create" {
    request "service" "CreateUser" {
        username = "{{ input:username }}"
    }

    rollback "service" "DeleteUser" {
        id = "{{ create:id }}"
    }
}

Headers

Headers contain keys and values which define constants or references. Headers are passed to the called and send to the service. Headers could be defined in both requests and rollbacks.

input "schema.Object" {
    header = ["Authorization"]
}

resource "create" {
    request "service" "Authenticate" {
        header {
            Authorization = "{{ input.header:Authorization }}"
        }
    }
}

When referencing header properties inside other resources remember that they have to be defined.

Flow resource branches

Nodes (resources) are executed concurrently from one another. When a node is executed a check is performed to check whether the dependencies have been met. Only if all of the dependencies have been met is the node executed.

+------------+
|            |
|    Node    +------------+
|            |            |
+------+-----+            |
       |                  |
       |                  |
+------v-----+     +------v-----+
|            |     |            |
|    Node    |     |    Node    |
|            |     |            |
+------+-----+     +------+-----+
       |                  |
       |                  |
+------v-----+            |
|            |            |
|    Node    <------------+
|            |
+------------+

Last updated