Basic idea of how to use Flor gem.

Basic idea of how to use Flor gem.

28 Sep 2022
Basic idea of how to use Flor gem.

As a workflow engine, flor takes in input process definitions and executes them. These executions, in turn, call pieces of Ruby code or external scripts to perform the actual work. Those pieces of code and scripts are referred to as “taskers”.

The flor workflow engine can be created as follows by installing the gem ‘flor/unit’ and asking the flor library inside the ruby file.

1. Add the command to your gem file:

  • gem ‘flor’

2. Run: bundle update.

3. Use the basic control-flow pattern in flor.

  • Sequence / cursor.
  • Parallel Split.
  • Synchronization.

4. Create a ruby file and add this code to it.

5. “Require flor” gem for using them in the entire program file.

6. Database connection:

The database is used to store the execution process. The user can use MySQL, PostgreSQL, and SQLite DB. The sequel does not support the MongoDB adapter.

  • Use the below-mentioned syntax while using the SQLite database.

  • Use this syntax while using the MySQL database.

7. Starting and launching the flor unit execution:

To begin the execution flow of flor, it is important to start the process using the ‘flor’ gem. After starting, it’s time to launch. During launch execution, it is important to mention the tasker to perform, according to the flow of execution.

Mentioned below are a few Basic Control flow patterns that can be used. Let’s explore how to execute the taskers in various patterns.

a) Sequence:

Executes the ‘child’ expressions(taskers) in sequence.


b) Parallel Split:

Here tasker performs concurrently. It replies to its parent node when both taskers have replied.


c) Synchronization:

It is the simplest flor synchronization tool. The concurrence waits (by default) for all its children to reply.


8. Adding tasker and Implementation class:

While adding the tasker it is required to specify the class where it will be executed. The implementation class will be ruby, which is inherited from ‘BasicTasker’. It also consists of an execution message.

The below code highlights how the user can perform the tasks with all the implementation related to the task. The user can fetch the data from DB and execution.

9. Tree format for flor:

  • In the below code, task ‘a’ and task ‘b’ is the child of sequence. In flor language, indentation holds more importance.

  • In the below example, task ‘a’ is the child of sequence and task ‘b’ is the child of task ‘a’.

Leave a comment: