Erlang in Practice Episode 7: Writing Servers with gen_server

Posted in Development on September 08, 2008


Erlang in Practice Episode 7: Writing Servers with gen_server

In the first half of this episode, we’ll learn how to write Erlang server processes using gen_server, a module in the OTP library. Then, in the second half of this episode, we’ll put what we learned into practice by incrementally refactoring two of our home-grown servers to use gen_server. As a result, you’ll be able to immediately apply gen_server to your next Erlang server process or one you’ve already written. You’ll learn how to:

  • write a generic Erlang server process using gen_server
  • design systems that decouple the message dispatch loop from the code that handles the messages for better reuse
  • send RPC and cast-style messages
  • initialize and shutdown gen_server processes
  • scope the server to control who sees the server and who can send messages to it
  • apply gen_server to a real-world problem
  • refactor existing servers to use gen_server

Watch Video

Tags: Erlang, Languages, RPC, The Pragmatic Programmers, Erlang in Practice