As of this weekend (and Benthos v3.13) you can now use a bloblang
processor and complementary condition. 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.
The Motivationโ
In the last post 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.
Using old processors:
pipeline:processors:- metadata:operator: setkey: barvalue: ${!json_field:foo.bar}- json:operator: deletepath: foo.bar- json:operator: setpath: foo.topicvalue: ${!metadata:topic}- metadata:operator: deletekey: topic- conditional:condition:jmespath:query: "foo.baz == 'thing'"processors:- json:operator: setpath: foo.thing_idvalue: ${!uuid_v4}
Using Bloblang:
pipeline:processors:- bloblang: |root = thisfoo.topic = meta("topic")meta topic = deleted()meta bar = foo.barfoo.bar = deleted()foo.thing_id = match {foo.baz == "thing" => uuid_v4()}
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, the Gitter channel, or event @ me on Twitter for the good of blobkind.