Upgrade to Pro — share decks privately, control downloads, hide ads and more …

OTP in 15 Minutes or Less

OTP in 15 Minutes or Less

Slides for my talk given at the Philly Elixir Meetup on the OTP part of Elixir/OTP.

Gavin M. Roy

August 04, 2016
Tweet

More Decks by Gavin M. Roy

Other Decks in Programming

Transcript

  1. OTP in 15 Minutes or Less Philly Elixir Meetup
 August

    2016 Gavin M. Roy VP of Architecture AWeber Communications
  2. Processes • Heart of Concurrency • Are light-weight independent tasks

    • Share nothing • Communicate via message passing • Implement a basic contract
  3. Processes • Are long lived in a message loop •

    Can link to other processes • Can spawn other processes • Can Crash!
  4. What is OTP? • The standard library that ships with

    Erlang • Design principles for code structure • A core set of common patterns and behaviors
  5. OTP Concepts • Applications • Collection of Modules • Runtime

    Structure / Processes • Supervisors • Manage Processes • gen_* Behaviors • Releases
  6. Applications • Application Resource File
 Defines application modules, defaults, and

    required OTP applications • Application Behavior
 start/2 and stop/1 {application, name, [ {description, ""}, {vsn, "1"}, {registered, []}, {applications, [ kernel, stdlib ]}, {mod, {server, []}}, {env, []} ]}.
  7. Supervisors Return a list of Child Specifications that • Defines

    the process IDs and MFAs • What to do if processes crashes • How to shutdown the processes • What type of processes the children are
  8. gen_server - init/1
 - handle_call/3 
 - handle_cast/2 
 -

    handle_info/2 
 - terminate/2 - code_change/3
  9. Other OTP Behaviors Built-In • gen_fsm (Deprecated)
 Finite State Machine

    • gen_statem
 Event State Machine • gen_event
 Generic event handling behavior 3rd Party Examples • gen_leader
 Distributed Master/Slave topology • gen_tcp_server
 Generic TCP Server • gen_rpc
 Scalable Multi-node RPC library