[udf] Unlock JavaScript for user-defined functions#667
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #667 +/- ##
==========================================
+ Coverage 49.75% 49.96% +0.21%
==========================================
Files 81 81
Lines 4034 4051 +17
==========================================
+ Hits 2007 2024 +17
Misses 2027 2027
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
b9c9618 to
e972049
Compare
3b47f82 to
8cd99f7
Compare
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Hi there,
after bouncing on and off on the idea to leverage the
javascriptpackage for data transformation purposes, in order to get rid of our PutsReq instance, which is a resource hog, and ceased to exist anyway, and while being unsure whether or how to also bring it to Kotori or LorryStream exactly, I am finally making a start on behalf of mqttwarn.On the PutsReq instance I was referring to, we are running small snippets of JavaScript code like putsreq.hiveeyes.ttn_v3.js, in order to converge telemetry data packages received from TTN into a format digested by Kotori, effectively just unwrapping a few levels of JSON nestedness.
Following this idea, and annoyed about PutsReq itself, we've also explored the problem space on behalf of other projects like flow-heater already. At about the same time, Cloudflare Workers have been released, allowing to route and modify HTTP requests in different ways, using JavaScript or TypeScript. /cc @elbart
This patch essentially brings the same idea to mqttwarn, where all the routing and transforming machinery is already in place, and just needed a laughably small patch to achieve the same things with JavaScript without much further ado, thanks to the excellent JSPyBridge by @extremeheat. 💯
By providing an alternative way of writing user-defined functions, the patch challenges the current slogan "primarily written in Python". I hope you will still like it, and I will be happy to hear back about your opinion about it.
Rest assured I am not a strong advocate of the JavaScript language, nor its paradigms and its NPM ecosystem 1. But I recognize the value of the V8 runtime underneath Node.js, that it's an excellent and robust piece of software, and that people are doing many amazing things of their own kind with it.
The preview of the corresponding documentation can be inspected here:
With kind regards,
Andreas.
NB: Next stop: Lua? Edit: See GH-669.
NB: Next stop: Java? See https://github.com/jpype-project/jpype and https://github.com/kivy/pyjnius.
NB: Next stop: Golang? See https://github.com/grumpyhome/grumpy.
Footnotes
https://www.destroyallsoftware.com/talks/wat ↩