Definition

A workflow describes the connections between events and tasks of services with a step-by-step system.

Workflows are defined in a YAML file called liteflow.yml.

A workflow has a list of steps. Each step indicates a specific action to do. There are three types of steps:

Here is an example of a typical project file containing one workflow.

liteflow.yml
workflows:
  hello-world:
    steps:
      - type: trigger
        service: http
        eventKey: request
        endpointKey: helloWorld
      - type: task
        service: js-function
        taskKey: execute
        handler: ./hello-world.js

Trigger

An event that will trigger the workflow.

  • Should be the first step of the workflow.
  • Only one trigger is possible per workflow.
  • It triggers the workflow when a matching event is emitted.

Triggers available:

Task

Defines the task to execute of a given instance of a service.

  • A workflow should have at least one task and can have as many as you want.

Tasks available:

Filter

Stop the execution of the workflow if a condition doesn't match. Apply one or multiple conditions on the previous step's outputs. All conditions should match to continue to the next step.

  • A workflow can have as many filters as you want.
  • Filters are optional.
KeyTypeDescription
type"filter"
conditionsmap<string, Value>Key-value map where the key references a data of the previous step's outputs and the value is the expected matching value

The simplest way to set conditions is to use a map<string, Value> where the key references a data of the previous step's outputs and the value is the expected matching value.

The condition value can be any of the following types:

  • string
  • bool
  • number
liteflow.yml
workflows:
  workflow-with-filter:
    steps:
      - ...
      - type: filter
        conditions:
          previousTaskOutput_1: 'hello' # the value of this output must be "hello"
          previousTaskOutput_2: 10 # the value of this output must be 10
          previousTaskOutput_3: true # the value of this output must be true

Advanced filter

You can create advanced filters with different predicate and references. Check out the filter documentation.

Environmental variable

You can override any value in the workflow file during the compilation by using the syntax ${ env.XXXX }, where XXXX is the name of the environmental variable defined in your .env file.

liteflow.yml
workflows:
  hello-world:
    - type: trigger
      service: http
      eventKey: request
      endpointKey: ${ env.FOO }
    - type: task
      service: js-function
      taskKey: execute
      handler: ./hello-world.js

Include file

When your project has many workflows, you can split the liteflow.yml file into multiple files.

To do so, you can use the syntax ${ file('path/to/file.yml') } to import a YAML file into another one.

liteflow.yml
workflows:
  hello-world: ${ file('workflows/hello-world.yml') }
workflows/hello-world.yml
steps:
  - type: trigger
    service: http
    eventKey: request
    endpointKey: helloWorld
  - type: task
    service: js-function
    taskKey: execute
    handler: ./hello-world.js