poc: Generic Mapper using JavaScript#3626
poc: Generic Mapper using JavaScript#3626didier-wenzek wants to merge 18 commits intothin-edge:mainfrom
Conversation
Codecov ReportAttention: Patch coverage is 📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
cbab55d to
c87474d
Compare
This commit is a very first step, scaffolding a generic mapper. The aim is to let users define their own mapping rules to tranform, filter or enrich data received from various sources. The idea is to form pipelines of user-provided transformation functions that: - consume messages from MQTT, - stream these messages along the transformation stages, - publish back to MQTT the resulting messages. Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
c87474d to
188fd01
Compare
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
…mapper Signed-off-by: James Rhodes <jarhodes314@gmail.com>
Signed-off-by: James Rhodes <jarhodes314@gmail.com>
NB This doesn't currently work since dynamic subscriptions aren't hooked up fully. tedge_mqtt_ext needs some further modifications to support sending the received messages on newly subscribed topics to the actor that requested the subscription Signed-off-by: James Rhodes <jarhodes314@gmail.com>
| } | ||
| }, | ||
| Some(InputMessage::FsWatchEvent(e)) => { | ||
| tracing::warn!("TODO do something with {e:?}") |
There was a problem hiding this comment.
We can definitely ignore anything that is is related to a file with an unknown extension (such as .collectd.toml.swp and collectd.toml~).
- Deletion of a pipeline should be okay, unless if we try to unsubscribe to the input topics.
- Deletion of a script is more problematic, if still used by one of the pipeline.
| /// | ||
| /// Default: An empty topic list | ||
| pub subscriptions: TopicFilter, | ||
| pub subscriptions: Arc<Mutex<TopicFilter>>, |
There was a problem hiding this comment.
A bit unusual to have interior mutability for a config struct - something granted as immutable.
| client: mqtt_channel::AsyncClient, | ||
| subscriptions: Arc<Mutex<TopicFilter>>, |
There was a problem hiding this comment.
I would combine these two fields of an mqtt_chanel::Connection in a single one (say a subscriber) that handles the whole logic below to compute the new subscription set and update mqtt_channel::AsyncClient.
| let to_sub = to_sub.filters(); | ||
| if !to_sub.is_empty() { | ||
| info!("Updating MQTT subscription to include {to_sub:?}"); | ||
| client.subscribe_many(to_sub).await.unwrap(); |
There was a problem hiding this comment.
NB This doesn't currently work since dynamic subscriptions aren't hooked up fully. tedge_mqtt_ext needs some further modifications to support sending the received messages on newly subscribed topics to the actor that requested the subscription
Okay, I understand this comment now. The MQTT subscription is correctly updated but the messages are not forwarded by this actor which ToPeers::peer_senders subscriptions list has not been updated.
Indeed, not easy to update from the FromPeers event loop this peer_senders list which is owned by the ToPeers event loop. A new channel, would be not enough as these peer Senders are anonymous. Which one would have to be updated?
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
|
Closing this POC which is superseded by #3650. The main reason being the executable size (59M - release build, dynamically linked, stripped) compared to the POC using QuickJS (17M - release build, statically linked, stripped) and tedge without any JS support (16M- release build, statically linked, stripped) |
Proposed changes
This POC explores an alternative to #3517
A thin-edge mapper that can be extended by users with mapping rules implemented in JavaScript.
Features:
MQTT sub| filter-1 | filter-2 | ... | filter-n | MQTT pubCriteria:
Examples:
Types of changes
Paste Link to the issue
Checklist
just prepare-devonce)just formatas mentioned in CODING_GUIDELINESjust checkas mentioned in CODING_GUIDELINESFurther comments