@@ -447,6 +447,19 @@ export its main entry point symbol, configure mqttwarn to use `functions = myclo
447
447
and adjust its settings to use your MQTT broker endpoint at the beginning of the data
448
448
pipeline, invoke mqttwarn, and turn off Kafka. It works!
449
449
450
+ On the next day, after investigating if you need to migrate any other system components,
451
+ you realize that there is an Nginx instance, which receives a certain share of telemetry
452
+ traffic using HTTP, and processes it using Lua. One quick ` mosquitto_pub ` later, you are
453
+ sure those telemetry messages are _ also_ available on the MQTT bus already. Another set
454
+ of transformation rules written in Lua was quickly identified, and, after applying the
455
+ same procedure of inlining it into a single-file version, and configuring another mqttwarn
456
+ instance with ` functions = mycloud.lua ` , you are ready to turn off your whole cloud
457
+ infrastructure, and save valuable resources.
458
+
459
+ After a while, you are able to hire back half of your previous engineering team, and,
460
+ based on the new architecture, you will happily start contributing back to mqttwarn,
461
+ both in terms of maintenance, and by adding new features.
462
+
450
463
:::{note}
451
464
Rest assured we are overexaggerating a bit, and [ Kafka] can only be compared to [ MQTT]
452
465
if you are also willing to compare apples with oranges, but you will get the point that
@@ -467,6 +480,15 @@ available [OCI images](#using-oci-image).
467
480
You can find an example implementation for a ` filter ` function written in JavaScript
468
481
at the [ OwnTracks-to-ntfy example tutorial] ( #owntracks-ntfy-variants-udf ) .
469
482
483
+ #### Lua
484
+
485
+ For running user-defined functions code written in Lua, mqttwarn uses the excellent
486
+ [ lupa] package. For adding JavaScript support to mqttwarn, install it using pip like
487
+ ` pip install --upgrade 'mqttwarn[lua]' ` , or use one of the available
488
+ [ OCI images] ( #using-oci-image ) .
489
+
490
+ You can find an example implementation for a ` filter ` function written in Lua
491
+ at the [ OwnTracks-to-ntfy example tutorial] ( #owntracks-ntfy-variants-udf ) .
470
492
471
493
472
494
## User-defined function examples
@@ -707,6 +729,7 @@ weather,topic=tasmota/temp/ds/1 temperature=19.7 1517525319000
707
729
[ Jinja2 templates ] : https://jinja.palletsprojects.com/templates/
708
730
[ JSPyBridge ] : https://pypi.org/project/javascript/
709
731
[ Kafka ] : https://en.wikipedia.org/wiki/Apache_Kafka
732
+ [ lupa ] : https://github.com/scoder/lupa
710
733
[ MQTT ] : https://en.wikipedia.org/wiki/MQTT
711
734
[ Node.js ] : https://en.wikipedia.org/wiki/Node.js
712
735
[ OwnTracks ] : https://owntracks.org
0 commit comments