A guide to Transformers

A guide on how to use the transformers on Alumio

The transformer is the smallest reusable unit of logic that is applied to a given data.

The concept attempts to illustrate the basic idea behind the transformers. The input to the transformer can be anything, if the data is suitable the transformer will apply its logic over it. Transformers can be chained together and the order of the transformers will also determine the output of the transformation.

Transformers allow us to transform data in a route. Transformers can be added to incoming configurations, to outgoing configurations, and to routes.

In the "Slideshows from httpbin to httpbin" route that we have created earlier, we retrieved data from an HTTP page, created a task with it, and finally sent the data to another HTTP page.

This data has the following form:

{
    "slideshow": {
    "author": "Yours Truly",
    "date": "date of publication",
    "slides": [ {
      "title": "Wake up to WonderWidgets!",
      "type": "all"
      },
    {
      "items": [
      "Why <em>WonderWidgets</em> are great",
      "Who <em>buys</em> WonderWidgets"
    ],
    "title": "Overview",
    "type": "all"
    } ],
    "title": "Sample Slide Show"
    }
}

Let's say we do not want to send the whole slideshow at once to the endpoint. Instead, we want to create a task for each slide and send the slides one-by-one.

This can be done by adding a transformer to the route configuration. To do so open the transformer configuration and click on "Add transformers". We select the transformer prototype called "Get branches from a pattern". We configure the transformer as follows:

  • Pattern: slideshow.slides.*

    When we execute the route again we see that two tasks have been created instead of one.

    Execute the incoming configuration from the dashboard by going to Connections > Incoming. Open the detail page by clicking the incoming configuration Then click the "Run Slideshows from httpbin" button.
    When we inspect the entity data of one of the new tasks we see that a node of the original data has been used to create the task.