Understand the core OTP abstractions in Gleam
mainGleam OTP provides three primary levels of abstraction for building fault-tolerant programs:
- Process: The lowest-level building block. While all actors are processes, you should generally favor higher-level abstractions like
actororsupervisorfor application logic. Note that theprocessmodule is defined in thegleam_erlanglibrary. - Actor: The standard building block for stateful logic. It provides type-safe message handling and manages OTP system messages automatically.
- Supervisor: A process designed to manage other processes. Supervisors can restart crashed processes or terminate them during shutdown. By nesting supervisors, you can create a supervision tree, which provides hierarchical fault tolerance and monitoring.