I want to know if we can implement flow based programming using a graph. Where each node is a process by itself, and the graph can be dynamic in nature. I’m not sure how I can achieve this in elixir. Please let me know your thoughts.
If you use Supervision tree you have - you guessed it, tree. Maybe that’s a partial solution?
The quick answer is yes. How would you use this graph flow based programming ?
@tty, I basically want to create REST API’s using the graphs.
Take a look at the flow library. It might provide the tools you are looking for .
flow isn’t related to the FBP paradigm
I still don’t quite get it. Are you intending each graph node as a state ? The edges as transitions to that state ?
I want to create something like this
Each node being a function
Yes that looks very possible. If each node is a function you have the choice of having an Elixir process handle one function or you can mimic all of these within a FSM. Unfortunately Elixir doesn’t have a corresponding Erlang gen_fsm / gen_statem and will have to use the Erlang behaviours.
I think state machines aren’t the answer to this. As we might me dealing with a function which requires more than one input argument, and they are waiting for the output from a different node, which can be of asynchronous nature.
Ok. Go with GenServer to begin with and model a simple system. It looks very doable.
There is an Elixir wrapper for gen_statem here…
Here’s a FBP library:
Take a look at this talk about the topic
What you are looking for is https://github.com/antonmi/flowex which mixes FBP and ROP, I’m personalize working on my own library called conveyer based on the following libraries:
I was exploring ‘ElixirFBP’ and is the closest to what I am looking for, thanks for finding the alternatives.
Here’s another relatively new library implementing FBP and is based on GenStage: https://github.com/suitepad-gmbh/pipette
I wrote about Elixir and FBP in a blog at the time that GenStage and Flow were announced.
Hi, I’ve created a proof-of-concept implementation.
Please have a look and let me know your views.
Any suggestions or contributions are welcome.
This is inspired by @pcmarks implementation.
I apologize for not getting back to you sooner - been very busy. I will take a look at your work in a few days.