Behaviours
- Behaviours. A behaviour is a formalised pattern: the generic half in OTP, your callbacks filling the specific half.
- Why behaviours. Decades of concurrency bugs are already solved in the generic halves: you inherit the fixes.
- Callback modules. Your module exports the callbacks: init, handle_call: and declares which behaviour it serves.
GenServer
- gen_server. A gen_server is the stateful-process behaviour: requests in, state threaded through callbacks.
- call versus cast. call is synchronous with a reply and a timeout; cast is fire-and-forget: choose per message.
- State threading. Callbacks receive state and return the new state: the process loop owns it between messages.
Standardising Concurrent Components
- One shape everywhere. OTP components share one shape: any Erlang engineer can read any gen_server on sight.
- sys and debugging. Behaviours speak to sys: processes traced, suspended and inspected live, in production.
- Timeouts and hibernation. Servers declare timeouts and hibernate when idle: long-lived processes tuned by contract.
Before and after this level
- Before: Level 5: Process Relationships: Links, Monitors, Exit Signals and Failure Propagation.
- Next: Level 7: Supervision: Supervisors, Restart Strategies, Supervision Trees.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does Erlang Level 6: OTP Foundations cover?
Behaviours, GenServer, Standardising Concurrent Components: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Level 5: Process Relationships, which covers Links, Monitors, Exit Signals and Failure Propagation.