FlowFuse / flowfuse

Connect, collect, transform, visualise, and interact with your Industrial Data in a single platform. Use FlowFuse to manage, scale and secure your Node-RED solutions.
https://flowfuse.com
Other
272 stars 63 forks source link

Project In / Project Out nodes for interproject communication #662

Closed ZJvandeWeg closed 2 years ago

ZJvandeWeg commented 2 years ago

Epic

No response

Description

As a: Developer

I want to: Use a custom node to send messages to another gateway

So that: it can continue to process the data

Acceptance Criteria

knolleary commented 2 years ago

This is blocked by #464 - and more specifically, the comments on security here

knolleary commented 2 years ago

We can make some progress on this in parallel to #464 - getting the node repository created and the basic structure of the nodes in place.

The nodes will require some settings to be provided via settings.js to cover the following:

Currently, a Project Access Token doesn't have access to the platform API - only the storage API used by the runtime storage plugin. This will require the project to be able to call an API to get a list of projects in the team. Whether that is the existing /api/v1/teams/XYZ/projects api, or one dedicated for projects to use is TBD. But we should take care to only expose the minimum of information needed (project id/name - no other details)

Steve-Mcl commented 2 years ago

Project links design notes

Concepts

The high level concept of project links is inbox/outbox
inbox being what is sent directly to a project (a project/device has its own inbox)
outbox being what a project broadcasts to anyone who cares to listen

Other notes...

Topic structures

Details (From the proposed Subscription ACLs)

Subscription ACLs Can subscribe to... Publish ACLs Can publish to...
Receive messages from other projects ff/v1/<team>/p/<own-project>/in/+/# Send messages to other projects ff/v1/<team>/p/<any-project>/in/+/#
Receive broadcasts from other projects ff/v1/<team>/p/<any-project>/out/+/# Send broadcast message ff/v1/<team>/p/<own-project>/out/+/#

project to project

broadcast

link call

Scenario "Wind Farm"

Regarding the initial design work for "Project Link" plugin, it is helpful to me (and hopefully others) to have a human digestible scenario based on the table of topics (https://github.com/flowforge/flowforge/issues/464#issuecomment-1155300019)

Team

A small team of 6 people manage a small wind farm (20 devices).

The team name for this scenario is "wind-farm-1"

Projects

Devices

project-main

project-v1

project-v2

Overview

  graph TD;
    classDef team fill:#555,stroke:#333,stroke-width:2px
    classDef project fill:#aaa,stroke:#333,stroke-width:2px,color:#000
    classDef device fill:#cef,stroke:#123,stroke-width:2px,color:#000

    PM[/project-main/]:::project---PD1[/project-v1/]:::project;
    PM----PD2[/project-v2/]:::project;

    PD1---PD2;
    PD1---Device_1:::device;
    PD1---Device_2:::device;
    PD1---Device_x:::device;
    PD2---Device_11:::device;
    PD2---Device_12:::device;
    PD2---Device_1x:::device;


Project-Link Nodes: design proposal

Figma: https://www.figma.com/file/hr6tk073P2lIDdLdrczMeK/Project-Link-Nodes?node-id=0%3A1

Base principles

Project-Link-Out (Project to Project)

UI (User Facing)

A node can target a specific project and send a msg via the "Send message to project" topic structure e.g.

Project-Link-Out (broadcast)

UI (User Facing)

A node can send a msg on the "Send broadcast" topic structure e.g.

Project-Link-Out (return)

The a project-link-out node requires a means of returning a message that originated from a project-link-call To know where to send the msg next, a LIFO stack in the msg will be required

Project-Link-Out Design

Philosophy - Project-Link nodes will transmit a msg just like the Link-in/out nodes. From the above descriptions, we can conclude the Project-Link-Out node requires the following fields...

Project-Link-In (Project to Project)

UI (User Facing)

The "in" node will receive a msg that is sent from another project when the topic matches a sent message and the message is directed to this project by selecting the source option "Receive messages sent to this project" Accessing data from project-v1 in project-main, the user would

Project-Link-In (broadcast)

UI (User Facing)

Accessing data from 1 or all projects in the team, the user would select the source option "Listen for broadcast messages from" then select all projects or a specific project and enter a sub-topic e.g. motor/1/speed

Backend

In accessing data from all projects in the team with topic motor/1/speed, the Project-Link-In node subscribes to ff/v1/wind-farm-1/p/+/out/motor/1/speed In accessing data from a specific project in the team with topic motor/1/speed, the Project-Link-In node subscribes to ff/v1/wind-farm-1/p/<project-id>/out/motor/1/speed

*Project-Link-In** Design

From the above, we can conclude the Project-Link-In node requires the following fields...

project-link-call (for command/response pattern)

The project-link-call node functions like the current link-call node in that it expects a project-link-out node to return the msg along with the original msg sub properties identifying the caller. To perform the command/response pattern, the MQTTv5 property responseTopic should be utilised. The project link will only support project-to-project (no broadcast) The project link call will support nested calls

UI (User Facing)

A timeout should be set. Default 30s (open to debate) A target project must be set A topic must be entered.

Backend

Design

From the above, this proposal suggests the use of MQTT v5 response topic for routing back to the caller.

Notes

Additional thoughts / iteration...

Steve-Mcl commented 2 years ago

@knolleary

The nodes will require some settings to be provided via settings.js to cover the following:

  • FlowForge API URL & token - to be able to query the platform to get a list of projects in the same team as this one.
  • Broker connection details - url/credentials

Something like (UPDATE 2022/07/25)...

flowForge: {
    baseURL: '${settings.storageURL}',  // FORGE_URL
    teamID:  '${settings.teamID}',  // the team hash passed via env var FORGE_TEAM_ID
    projectID: '${settings.projectID}',  // FORGE_PROJECT_ID
    deviceID: '${settings.projectID}',  // present if deployed to a device?
    projectLink: {
        token: '${settings.projectToken}',
        broker: {
            url: xxxx // value computed from platform
            username: xxxx,  // value computed from platform
            password: xxxx,  // value computed from platform
            clientId: null  // value computed from platform? // << generated from username + ":n" if missing
        }
    }

communication path look like...

node-red project link node (UI)node-red project link node (Runtime endpoint)platform (GET '/:teamId/projects')launchernode-red project link node ?

sammachin commented 2 years ago

Discussion on where these would fit within our Pricing (https://flowforgeworkspace.slack.com/archives/C032Q63FGG1/p1658494235857459)

[nick]
Where do the Project nodes sit on the pricing plan then?
[nick]
I don’t see them listed in the pricing table
[Sam Machin]
:thinking_face: I don’t think we have any capability in the current billing concepts for controlling nodes based on tier,
We could limit their access based on a template? but templates are not associated to projectTypes,
I guess we could include them in the stack when its built? that could then limit them to specfic project types, and would be preferable over having them installed from npm anyway?
I’m just thinking through the scenarios of a user having 2 projects (small and medium) but they can’t communicate between them.
The ideal place from a user perspective is in the team tier I think, then you get it on all the projects that team has,
[nick]
Personally I think the nodes should be a CE feature
[nick]
… if they are a team tier thing, then we can’t ship them until we have team tiers
[nick]
or if it is a CE -vs- EE thing, then we need to add license checks into all the work I’ve done so far
[nick]
and move the code to the EE part of the code base
[Sam Machin]
I can see that trying to retrofit them to billing isn’t ideal, and we don’t have all the capabilities that we would need to do that right now anyway.
I’m just very aware that we’re still giving away all our value add at the lowest tiers which makes it harder to drive the higher revenue points…. 
[Sam Machin]
However from an FF cloud perspective I can see that these nodes make it more useful to have multiple projects (rather than several sets of flows in one) and that in turn would drive revenue
[Sam Machin]
Based on that lets keep these nodes as a CE feature, but it does highlight the importance of getting the billing and licensing frameworks into a ready state before we build more features 

Summary, Inter-project Communications Nodes will be available to all Editions and Tiers.

ZJvandeWeg commented 2 years ago

I'm worried that we're throwing away differentiating features this way. We should be building the Delta between CE and EE. Every release it stays the same is a missed opportunity from the product sales perspective Op 25 jul. 2022 09:57 schreef Sam Machin @.***>:

Discussion on where these would fit within our Pricing (https://flowforgeworkspace.slack.com/archives/C032Q63FGG1/p1658494235857459)

[nick]

Where do the Project nodes sit on the pricing plan then?

[nick]

I don’t see them listed in the pricing table

[Sam Machin]

:thinking_face: I don’t think we have any capability in the current billing concepts for controlling nodes based on tier,

We could limit their access based on a template? but templates are not associated to projectTypes,

I guess we could include them in the stack when its built? that could then limit them to specfic project types, and would be preferable over having them installed from npm anyway?

I’m just thinking through the scenarios of a user having 2 projects (small and medium) but they can’t communicate between them.

The ideal place from a user perspective is in the team tier I think, then you get it on all the projects that team has,

[nick]

Personally I think the nodes should be a CE feature

[nick]

… if they are a team tier thing, then we can’t ship them until we have team tiers

[nick]

or if it is a CE -vs- EE thing, then we need to add license checks into all the work I’ve done so far

[nick]

and move the code to the EE part of the code base

[Sam Machin]

I can see that trying to retrofit them to billing isn’t ideal, and we don’t have all the capabilities that we would need to do that right now anyway.

I’m just very aware that we’re still giving away all our value add at the lowest tiers which makes it harder to drive the higher revenue points….

[Sam Machin]

However from an FF cloud perspective I can see that these nodes make it more useful to have multiple projects (rather than several sets of flows in one) and that in turn would drive revenue

[Sam Machin]

Based on that lets keep these nodes as a CE feature, but it does highlight the importance of getting the billing and licensing frameworks into a ready state before we build more features

Summary, Inter-project Communications Nodes will be available to all Editions and Tiers.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

knolleary commented 2 years ago

We discussed this at length in today's Product Review meeting and explored the available options.

The conclusion was to look at the feasibility of making this an EE-only feature (available to all teams/projects on an EE licensed platform).

I will scope out what it would take to make the product nodes covered by the EE license.

Steve-Mcl commented 2 years ago

@ZJvandeWeg can this be closed now?