Establish Your Boundaries

The boundary layer deals with side effects and state. This layer is where you’ll deal with processes, and where you’ll present your API to the outside world. In Elixir, that means OTP.

We want to dispel the notion that each time you type mix new, you must reach for a GenServer, the fundamental abstraction in OTP. The first way to win the boundary game is not to play. Some projects don’t need boundary layers at all. If you’re building a library of functions that doesn’t need processes, don’t add them. Your code is a library and can present an API that serves your purposes just fine. There’s no boundary; no GenServer; no lifecycle. Your library will serve other software systems that provide this infrastructure, but it ...

Get Designing Elixir Systems With OTP 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.