github.com/Jeffail/benthos/v3@v3.65.0/website/blog/2020-05-10-bloblang-beta.md (about)

     1  ---
     2  title: Bloblang Beta
     3  author: Ashley Jeffs
     4  author_url: https://github.com/Jeffail
     5  author_image_url: /img/ash.jpg
     6  description: Available in v3.13
     7  keywords: [
     8      "benthos",
     9      "bloblang",
    10      "go",
    11      "golang",
    12      "stream processor",
    13      "mapping",
    14  ]
    15  tags: [ "Bloblang" ]
    16  ---
    17  
    18  As of this weekend (and [Benthos v3.13](https://github.com/Jeffail/benthos/releases/tag/v3.13.0)) you can now use a [`bloblang` processor](/docs/components/processors/bloblang) and complementary [condition](/docs/components/conditions/bloblang). These components are in a beta phase, which means that based on feedback the mapping language might change in minor ways in upcoming minor releases.
    19  
    20  <!--truncate-->
    21  
    22  ## The Motivation
    23  
    24  [In the last post][post.sneak_peek] I outlined my motivations for experimenting with a mapping language. Words are stupid and boring and so to illustrate why a mapping language kicks ass here's a config example using the old processors compared to the new one. Keep in mind that the new version is simpler _and_ performs better.
    25  
    26  Using old processors:
    27  
    28  ```yaml
    29  pipeline:
    30    processors:
    31    - metadata:
    32        operator: set
    33        key: bar
    34        value: ${!json_field:foo.bar} 
    35  
    36    - json:
    37        operator: delete
    38        path: foo.bar
    39  
    40    - json:
    41        operator: set
    42        path: foo.topic
    43        value: ${!metadata:topic} 
    44  
    45    - metadata:
    46        operator: delete
    47        key: topic
    48  
    49    - conditional:
    50        condition:
    51          jmespath:
    52            query: "foo.baz == 'thing'"
    53        processors:
    54        - json:
    55            operator: set
    56            path: foo.thing_id
    57            value: ${!uuid_v4}
    58  ```
    59  
    60  Using Bloblang:
    61  
    62  ```yaml
    63  pipeline:
    64    processors:
    65    - bloblang: |
    66        root = this
    67  
    68        foo.topic = meta("topic")
    69        meta topic = deleted()
    70  
    71        meta bar = foo.bar
    72        foo.bar = deleted()
    73  
    74        foo.thing_id = match {
    75          foo.baz == "thing" => uuid_v4()
    76        }
    77  ```
    78  
    79  My ultimate intention is to completely eradicate the need for a `json`, `metadata` and `text` processor, as well as a range of others. However, I'll need as much help as possible to get the language right, so please consider testing and feeding back on [Github][gh.issues], the [Gitter channel][gitter], or event @ me [on Twitter][twitter] for the good of blobkind.
    80  
    81  [processor.bloblang]: /docs/components/processors/bloblang
    82  [condition.bloblang]: /docs/components/conditions/bloblang
    83  [post.sneak_peek]: /blog/2020/04/18/sneak-peek-at-bloblang
    84  [gh.issues]: https://github.com/Jeffail/benthos/issues/439/
    85  [gitter]: https://gitter.im/jeffail-benthos/community
    86  [twitter]: https://twitter.com/Jeffail