2. Hello!
I am Anton Mishchuk
▷ Ruby developer at Matic Insurance Services
(we are hiring!)
▷ A big fan of Elixir programming language
▷ Author and maintainer of:
ESpec and Flowex libraries
github: antonmi
2
8. Flow-Based Programming is
a programming paradigm which
models application as a graph of
independent processes exchanging
data across predefined connections
8
10. FBP advantages
▷ Parallelism are natural
▷ No problems associated with shared
memory and locks
▷ Visualisation of data flow networks is simple
▷ Components are independent and reusable
10
11. Two layers in FBP application
▷ “Bottom layer” - set of components
implementing parts of business
logic
▷ “Top layer” - “communication logic”
- an organization of data flows
from one component to another
11
12. “Bottom layer” - components
▷ Component is independent unit
with input and output
▷ The only thing it does - transform
input IP to output IP
▷ In general, can be implemented
using any programming language
12
13. “Top layer” - communication
▷ Need “coordination language”
▷ Actor model of Elixir/Erlang
▷ GenStage
13
14. GenStage
▷ behavior for exchanging events with
back-pressure between Elixir processes
▷ José Valim defined GenStage as “better
abstractions for working with collections”
▷ but we can use it for “better interprocess
communication”
14
16. Flowex
▷ a set of abstractions built on top Elixir
GenStage which allows writing
program with FBP paradigm
▷ a mix of FBP and Railway Oriented
Programming (ROP) approach
16
25. “error_pipe”
If an error happens in some pipe, functions
in next pipes will not be called and IP will be
bypassed to the “error_pipe”
25
26. Run pipeline via
Flowex.Client
▷ Use Clients for
parallel processing of
many IPs
▷ Allows effective using
of pipeline even with
synchronous “call”
26
30. Advantages of Flowex approach
30
▷ Explicit definition of:
- structure of data will be processed
- way the data will come
▷ Easy to maintain and reuse:
- predefined set of working processes
- components are isolated and reusable
▷ Controlled parallelism:
- one can control number of clients
supplying data
- one can control the number of processes
available for each component
32. Why do we need this?
▷ Elixir/Erlang ecosystem is not so big as
Java, Ruby, Python, etc.
▷ Elixir/Erlang is not the fastest platform
▷ There are not so many Elixir/Erlang
developers
32
33. Erlang ports
▷ provide a byte-oriented interface to an
external program over STDIN and STDOUT
▷ are process-specific resources - only owner
process can talk to external process
▷ are flexible, safe and allows error trapping
33
34. ErlPort project
▷ helps connect Erlang to other
programming languages
▷ currently supported external languages
are Python and Ruby
▷ has Elixir wrapper - export
Read more on erlport.org
34
35. Porcelain project
▷ helps launching and communicating with
external OS processes from Elixir
▷ launches external programs in a
synchronous or asynchronous manner
▷ implements multiple ways of passing input
to the program and getting back its output
Read more on alco/porcelain 35
37. MultiFlowex pipeline
▷ There will be Ruby, Python and shell “pipes”
▷ Each will say “Hello”
▷ The result will be:
“Hello from Ruby, Hello from Python, Hello
from shell”
37
49. Conclusion
49
▷ FBP paradigm is an advantageous
alternative to “conventional programming”
▷ Flowex makes it easy to convert sequential
code into a pipeline of independent
components
▷ Erlang ports open new horizons,
so you can leverage the advantages of
other programming languages