Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Elixir par

157 views

Published on

Elixir OTP

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Elixir par

  1. 1. BY MICHEL PEREZ ELIXIR & PARALLEL PROGRAMMING
  2. 2. CONCURRENCY VS PARALLELISM
  3. 3. ELIXIR MECHANISMS ▸ PROCESS ▸ SPAWNING ▸ OTP ▸ GEN SERVER ▸ SUPERVISOR ▸ APPLICATION
  4. 4. PROCESSES ▸ Processes are the fundamental unit of concurrency in Elixir ▸ The Erlang VM supports up to 134 million of processes ▸ Lightweight processes ▸ Each actor is a process ▸ Each process performs a specific task ▸ Sends messages to communicate with the process ▸ The processes don’t share information
  5. 5. SPAWNING A PROCESS
  6. 6. PID ▸ Identifies a process in the EVM ▸ To send a message must point the pid
  7. 7. OTP ▸ The Erlang interpreter and compiler ▸ Erlang standard libraries ▸ Dialyzer, a static analysis tool ▸ Mnesia, a distributed database ▸ Erlang Term Storage (ETS), an in-memory database ▸ A debugger, ▸ An event tracer ▸ A release management tool
  8. 8. OTP BEHAVIOURS ▸ GenServer A behaviour module for implementing the server of a client-server relation. ▸ Supervisor A behaviour module for implementing supervision functionality ▸ Application A module for working with applications and defining application callbacks.
  9. 9. GEN SERVER - MODULE CALLS ▸ GenServer.start_link/3 ▸ GenServer.call/3 ▸ GenServer.cast/2
  10. 10. GEN SERVER - CALLBACKS ▸ init(args) ▸ handle_call(msg, {from, ref}, state} ▸ handle_cast(msg, state} ▸ handle_info(msg, state) ▸ terminate(reason, state) ▸ code_change(old_vsn, state, extra)
  11. 11. GENSERVER - INIT ▸ init(args) ▸ {:ok, state} ▸ {:ok, state, timeout} ▸ :ignore ▸ {:stop, reason}
  12. 12. GENSERVER - HANDLE CALL ▸ handle_call(msg, {from, ref},state) ▸ {:reply, reply, state} ▸ {:reply, reply, state, timeout} ▸ {:reply, reply, state, :hibernate} ▸ {:noreply, state} ▸ {:noreply, state, timeout} ▸ {:noreply, state, hibernate} ▸ {:stop, reason, reply, state} ▸ {:stop, reason, state}
  13. 13. GENSERVER - HANDLE CALL ▸ handle_cast(msg, state) ▸ {:noreply, state} ▸ {:noreply, state, timeout} ▸ {:noreply, state, :hibernate} ▸ {:stop, reason, state}
  14. 14. GENSERVER - HANDLE INFO - TERMINATE ▸ handle_info(msg, state) ▸ {:noreply, state} ▸ {:noreply, state, timeout} ▸ {:stop, reason, state} ▸ terminate(reason, state) ▸ :ok
  15. 15. GENSERVER - CODE CHANGE ▸ code_change(old_vsn, state, extra) ▸ {:ok, new_state} ▸ {:error, reason}
  16. 16. GENSERVER - EXAMPLE
  17. 17. SUPERVISOR ▸ Strategies ▸ :one_for_one ▸ :rest_for_one ▸ :one_for_all ▸ :simple_one_for_one
  18. 18. SUPERVISOR - EXAMPLE
  19. 19. APPLICATION ▸ Component implementing some specific functionality, that can be started and stopped as a unit, and which can be re- used in other systems ▸ Defines a supervision tree that must be started and stopped when the application starts and stops ▸ The start callback should return {:ok, pid}
  20. 20. APPLICATION - EXAMPLE
  21. 21. EXTREME B1N1 N2 N3 N4 F1 N5
  22. 22. EXSTREME - CREATING A GRAPH
  23. 23. EXSTREME - RUNNING THE GRAPH
  24. 24. EXSTREME - NOTES ▸ https://github.com/mrkaspa/Exstreme ▸ Future ▸ Add Backpresure (GenStage) ▸ Supervising ▸ Remote nodes
  25. 25. THANKS!

×