OTP
August 22, 2023 1 minutes • 158 words
Table of contents
OTP is made up of:
- Elxir Tool Set
mix
: a build toolapplication
: sets the other independent Modules that will run
- Erlang OTP Features
ETS
: Erlang Term Storagemnesia
: Database Management Systemcrypto
- Behaviors
- GenServer: has client and server
- Supervisor: manages workers in a GenServer
- Protocols: allows polymorphism. An example of a bult-in protocol is
String.Chars
OTP Processes and State Management
This allows functions to hold data independent of the function which is really held through the Genserver. This makes the OTP a real app.
Processes
- runs the actual functions and modules in memory
- has PID
Tasks: Start-Stops a Function or Module on a Process
- Runs a single process such as polling
- 1 task : 1 process
- has no state
Task.start(function_name)
Agents: Adds Lightweight State management on a Process
Only gets and updates single states. This makes it faster.
Genservers: Adds Heavy Duty State management on a Process
Gets, manipulates, and updates states by allowing “messages”.