-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change the message layout #28
Comments
Actuallt, the The block allows filtering out messages when there are no change to the payload (or in our case, in the payload.value when reading one and one data point from the source). If set up to be per topic, this method can be used to filter messages where the data doesn't change from one point to another. |
So with that, I think I will recommend Alt1 with the Input ID in the topic: Alt 1: Single signal (topic variant)msg:
topic: "<Input ID>"
payload:
times: ["<timestmap>", ...]
values: [(<number>||null), ...]
signal: <Signal> // Exact match with RPC Signal object from the reference docs. I won't deny there could be interesting use-cases for Alt2, but I am currently quite happy with the idea of prioritizing the single signal flows. This means prioritizing flows that helps get (the right amount) of data into Clarify, and then see if the problem of aggregation can perhaps be solved within Clarify itself. |
Updated proposal text to match previous comment. |
Updated the format of the messages according to this proposal: #28 The Input ID is put in msg.topic The signal meta data is moved out of the payload to msg.signal msg.payload.data.times is renamed/moved to msg.payload.times msg.payload.data.series is renamed/moved to msg.payload.values New message format: msg: topic: "<Input ID>" payload: times: ["<timestamp>", ...] values: [(<number>||null), ...] signal: <Signal> // Match https://docs.clarify.us/reference#signal
Implemented Alt1. Will look into supporting Dataframe in later releases. |
UPDATED.
The final proposal is that we should change the message format so that we end up with:
The Input ID is put in
msg.topic
to allow simpler topic based rate-limiting or down-sampling flows using standard rbe or delay blocs.The signal meta data is moved out of the payload to:
msg.payload.series
is renamed tomsg.payload.values
to better distinguish the payload format from the API v1 Data Frame format.It is further proposed that the Advanced Settings section where you can remap the message fields is removed, fully committing to the final format. Remapping is either way going to be an easy thing to do via a Change or Function block when needed.
Original text (deprecated)
Problems to solve
There are a few problems we can address with the current message design.
Meta-data and data in same parameter
Everything (data and metadata) is combined in the payload (by default). This makes it hard both mentally and programmatically to check if meta-data is provided or not. It also makes it more complicated to provide metadata data for the cases where all signal meta-data is statically configured.
Drift between Node-RED format and RPC documentation
The format is similar to, but still not exactly equal to the Clarify JSON RPC API. Making the formats more equal where it's practical, could make documentation and understanding easier.
Main issues:
data
object has the same field names as the Clarify JSON RPC API "Data Frame", but only the content of the"times"
field match exactly. The"series"
field is a map of Input ID to an array of values in RPC, while it's an array of values in Node-RED.Note on the current design
In the current design, We expect each message arriving the insert block to hold only one signal. While this makes the Data Frame format different in Node-RED than in RPC, it has clear benefits when creating flows, because it becomes easier to manipulate / alter each individual message (e.g. by inserting meta-data).
There could still be use-cases for allowing multiple signals per message, like allowing aggregation of multiple signals through a set of standard blocks. That is, if we have a use-case for doing this inside Node-RED, and we expect numbers that can be used to perform the aggregation to arrive in the same message. Multi-signal messages will on the other hand complicate single-signal manipulations because each of them involve either a map traversal or key lookup.
Allowing multiple data formats likely isn't a good idea, because this makes any attempt of later adding aggregate blocks near impossible. Therefore, we should either stick with single-signal messages, or migrate to multi-signal messages.
Next version message design
Update: Remove the original proposal of adding a separate "format" and "insert" block. A format block would likely either be too complex or not complex enough. It seams better to let this be done by custom functions, which are unavoidable in practice anyways.
Main goal:
Insert message design
Below are a few alternatives for a new message format. This can either be enforced, or done by changing the default values in the current advanced options section.
Alt 1: Single signal
Achieves:
signal
field to exactly match Signal Info RPC docs.series
tovalues
to better highlight the difference from the Data Frame'sseries
field in the RPC docs.Variation: rename
"input"
field to"topic"
.A possible variation of this format is one where we replace the
"input"
key with the key"topic"
. This is because the"topic"
filed is treated specially by some blocks in particular, such as the rate limiter (a.k.a. "delay") block. There may be more blocks that treats"topic"
differently, and we should investigate if there are any good use-cases where having the Input ID in the topic would be useful.Relevant questions:
"topic"
in a way where enforcing it to contain an Input ID has a benefit?Docs on using topic: https://nodered.org/docs/developing-flows/message-design#using-msgtopic
Alt 2: Multi signal
Achieves:
inputs
field to exactly matchintegration.saveSignals
RPC method'sinputs
parameter.payload
field to exactly matchintegration.insert
RPC method'sdata
parameter.Note on backwards compatibility
How much we need to care about backwards compatibility for this change depends on how much this plugin is used. We can probably get some numbers on this on the Clarify side. It also depends on when we do this. E.g. do we do it before the v1, for v2, or as a v1.x feature.
Here are some options for backwards compatibility:
The text was updated successfully, but these errors were encountered: