Blueprint of Our Boundary Layer
Explore designing the boundary layer in Elixir projects by implementing service and API layers using OTP GenServers. Understand how to manage state, handle errors, and create synchronous and asynchronous API calls with separate quiz session and manager processes.
Implementing the boundary layer
Recall our simple counter that wrapped a tiny core with processes and recursion to manage state. That wrapper is our service layer. We then took that ad hoc server and wrapped it in an API. This last layer exists as a convenience.
Structure of the boundary layer
We’re going to follow the same pattern here. Think about the boundary in two parts:
-
The service layer
-
The API layer
A boundary needs a service layer around each process type and an external API for clean, direct access across services. In Mastery, we’ll first need to decide what our GenServers are. We’ll need a service layer for each of two GenServers:
-
A quiz session where users ...