Disclaimer: The author is a newbie in OTP having some basic knowledge of Erlang's syntax, processes and messages.
I am trying to grasp the notion of behaviours in Erlang, but a lot of questions spring in my head preventing me from understanding the whole principle of such a behaviour like gen_server.
Okay, the official documentation for gen_server shows a nice diagram of a server and three clients connected with Query and Reply arrows: http://www.erlang.org/doc/design_principles/gen_server_concepts.html
But each time I try to understand the concept further, I get stuck.
There is a lot of concepts which I cannot build into one larger concept in my head:
- behaviour implementation;
- behaviour container;
- behaviour interface;
- callback module;
- callback functions;
- API functions.
I use the following resources:
- Erlang/OTP in Action book;
- Introduction to OTP behaviours presentation, http://www.slideshare.net/gamlidek/ceug-introduction-to-otp-behaviors-part-i-genserver;
- 'ErlyBank' at http://spawnlink.com/articles/an-introduction-to-gen_server-erlybank/index.html.
I am still in the state "we call one function in one module, this function calls the other function, that function creates a process... stuck"
Is there any way to describe the notion of gen_server in a diagram? How can an interaction flow between clients and a server be shown visually? (to help a not so smart newcomer to understand the concept visually)
For example like here: http://support.novell.com/techcenter/articles/img/dnd2003080506.gif
UPD: I have tried to draw a diagram of my own, but I still don't get the purpose of any connector in the diagram: http://postimage.org/image/qe215ric/full/
UPD2: This is something similar to what I would like to see: http://cryptoanarchy.org/wiki/Worker_patterns (The Model). However, it doesn't show the interaction between modules, functions and processes.