The Road to the Generic Server

This is the most important section in the entire book, so read it once, read it twice, read it a hundred times—just make sure the message sinks in.

This section is about building abstractions; we’ll look at a module called gen_server.erl. The gen server is one of the most commonly used abstractions in the OTP system, but a lot of folks never look inside gen_server.erl to see how it works. Once you understand how the gen server was constructed, you’ll be able to repeat the abstraction process to build your own abstractions.

We’re going to write four little servers called server1, server2, server3, server4, each slightly different from the last. server4 will be similar to the gen server in the Erlang distribution. ...

Get Programming Erlang, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.