Skip to content
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

Singleton connections #93

Open
ywadi opened this issue Apr 30, 2021 · 7 comments
Open

Singleton connections #93

ywadi opened this issue Apr 30, 2021 · 7 comments
Assignees
Milestone

Comments

@ywadi
Copy link

ywadi commented Apr 30, 2021

Hello, this is an awesome project!
Just need to clarify something as it is not in the docs, or might not have been in the scope.
I am creating a pub/sub connector to MQTT, I want to be able to connect to the server once with the username and password. But then share that connection with all the nodes that will be using the MQTT connection. Is that possible ? If not, is it in the scope? If it is I would be happy to help on that if you point out where this needs to be included

@steve2507
Copy link
Contributor

steve2507 commented Apr 30, 2021

There is a way to make an output act as 'global', as per the docs. Simply double click the output, and all inputs consuming that type will automatically be connected, without cluttering the UI. Only when you hover a global output, or related input, will the connectors visualize.

See below for an example.

  • Within the mongodb node, the mongodb output is set as global, and the mouse is hovering that output (hence you see the connections)
  • Both mongodb.collection nodes have their collections output set as global, automatically connecting them to the mongodb.collection.insert/collections input. Hovering either output or input would visualize the connections just like the mongodb/mongodb output which is currently highlighted.
    xible_global_ex

Let me know if that answers your question!

And yes, the docs definitely need at least a screenshot on this :-)

@ywadi
Copy link
Author

ywadi commented May 2, 2021

Thanks for your response @steve2507 ,
This kind of works for each workflow, let me put it this way, if you have multiple workflows then we will have multiple connections to the mongodb database if each workflow has the mongodb connection node, which is not the best practice in this case for performance on both end (the db and xible) as this will have multiple open connections.
I was assuming the ability to create 1 mongodb connection that can be shared between multiple workflows, so a global connection to all workflows where the connection object can be shared.
Hope that clarifies it? If this is something that you aim to add to xible, I dont mind contributing on that front.

@steve2507
Copy link
Contributor

steve2507 commented May 3, 2021

Yeah any thoughts on this would be appreciated. Back when I used Xible for home automation, I had a similar 'issue' and was thinking about creating a separate 'global flow' or something like that to store nodes which are exposed to every flow available.

@ywadi
Copy link
Author

ywadi commented May 5, 2021

Update: This wont work below as I noticed each flow runs a different PID, wont be able to share singleton objects, just keeping the below for inspiration for other ideas

A suggestion would be that the node that has been created that will be "connecting to a server or serving a global connection" would contain an executable file defined in the structure and the execution of this code returns an object (server connection for example) as a singleton. EXAMPLE:
Mongodb connect to server node will contain the following;

  • Structure File : Add description somehow that it will contain connection defs. that are generated as an object form the editor "Many connection types that can be used on multiple nodes" which would contain as an example ("server host, port, username, password")
  • Index.js File :
  • SingletonDefinitions.js "Need a better name" : Which will contain the ability to load the configurations defined on the editor as an object, executed and saved as a singleton.

when using this node, the user will have a dropdown list asking which configuration it would use (the predefined configurations).

Might be tricky to explain in text for now but do you get the gist of it ?

@steve2507
Copy link
Contributor

You already concluded this I see, but indeed every flow runs as its own process to not hinder each other in the case of computational intensive tasks. This will also allow for clustering a Xible setup later versions.

I do believe what you need is possible, without any extra development from a nodepack developer, simply by letting a Xible user define some nodes (such as the mongodb one) in a central place.

@ywadi
Copy link
Author

ywadi commented May 23, 2021

Would you have a suggestion on how to proceed with that ?
The multi-process approach makes total sense

@steve2507
Copy link
Contributor

Yes, I think so.
I'm currently working on a solution where a flow can import any other flow (the flow definition, not a flow instance). This would make it possible to simply store connection nodes and such in one flow and include that flow in others.
A next step would be to make a special place available for a 'global' flow that by default is included in all flows.

@steve2507 steve2507 self-assigned this May 28, 2021
@steve2507 steve2507 added this to the 1.0.0 milestone May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants