what is the boundary layer
what does the boundary layer deal with?
side effects and state
What are the rules for functions in the functional core?
describe strategies for defining functions in the functional core to make them pipeable
a module has a single concept, and each function taking a common datatype as it’s first arg. When the functions also return the modules struct, it’s also easier to pipe.
Complex multipurpose functions break down into pipes of single-purpose functions
List the signs of good Elixir code
List the 3 parts of the boundary layer
boundaries, workers, lifecyle P. 100
describe “the boundary”
An optional layer of impure integration code that makes the core fast, robust, and reliable
describe “the lifecycle”
provides tools to start and stop the boundary layer
describe “workers”
divide work for performance, isolation, or reliability
Name 5 scenarios you should consider using processes
What is the job of the API layer?
To insulate the server layer from inconsistent data and to stitch together independent concepts from the individual GenServer implementations.
It can also hide implementation details from the user.
What is the most important design concept when designing the API layer
To keep the API layer as thin as possible, and take on as little business logic as possible
how do you check a Process’s message mailbox length?
defp message_queue_length() do
{:message_queue_len, messages} = Process.info(self(), :message_queue_len) messages
endshould you prefer call or cast?
Call, it provides backpressure and serializability
what are some cases where you may need to judisciously use cast instead of call?
when starting multiple workers at once, or when notifying multiple workers simultaneously.
Define the purpose of a worker
The worker layer exists to manage concurrency using a variety of tools: naked processes, connection pools, tasks, and other dependencies….
A worker is process machinery that lets us divide labor for reliability, performance, or scalability
where does worker code go?
Worker code lives in the boundary with the rest of our process machinery.
What is the worker layer?
the process machinery that manages concurrency apart from lifecycle policy
Explain why you’d use a worker layer
Three primary motivations for introducing a worker layer: concurrency, isolation and scalability. Concurrency is a focused issue that allows more than one task to happen at a time, often reducing latency or enabling a feature like a scheduler. Isolation improves system reliability by limiting the damage any single bug can do by crashing a process. Scalability is a broader architectural concern, allowing one program to run across many processes.
List 2 tools for implementing a worker layer
GenServers, Tasks
How can you provide back pressure when using concurrency
prefer handle_call to handle_cast
Make use of async_stream (P. 159).
What you really need is a way to spread that work out. Even better, you would like to divide the work optimally, based on the number of cores supported by your hardware. Thats what async_stream does
list the parts of the boundary layer
boundary API, lifecycles, and workers
How can you silence logs in ExUnit
ExUnit.CaptureLog.capture_log P. 198
Or, @moduletag capture_log: true P. 208
Name one sign that your abstractions are right
if your abstraction is right, your tests should be simple. P. 199