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

What's the fuss about Phoenix?

What's the fuss about Phoenix?

WebCamp Zagreb, 2016

Saša Jurić

October 31, 2016

More Decks by Saša Jurić

Other Decks in Programming


  1. What’s the fuss about Phoenix? @sasajuric

  2. Phoenix web framework Elixir programming language Erlang VM written in

    runs on
  3. productivity simplicity maintainability interoperability fault-tolerance scalability

  4. Erlang is a programming language used to build massively scalable

    soft real-time systems with requirements on high availability. erlang.org
  5. None
  6. None
  7. separate execution no shared memory separate garbage collection cooperation through

    communication isolated crashes detectable crashes of other processes
  8. run different "things" separately

  9. scheduler scheduler scheduler scheduler CPU CPU CPU CPU Erlang VM

  10. Node 1 Node 2 Node 3

  11. None
  12. None
  13. DEMO

  14. conn conn your code

  15. conn conn plug

  16. conn log conn handle authenticate authorize fetch session

  17. endpoint conn conn router controller

  18. endpoint conn conn router controller endpoint conn conn router controller

    endpoint conn conn router controller
  19. CODE

  20. client server socket

  21. client server

  22. client server join "lobby" send "room:42", "message", payload send "room:42",

    "message", payload socket send “lobby", "rooms", payload join "room:42"
  23. socket client channel channel socket client channel channel

  24. import Socket from "phoenix" socket = new Socket("/socket") socket.connect() room

    = socket.channel("room:elixir", payload) room.join()
  25. room.push("some_event", payload) room.on("some_event", (payload) => { // ... })

  26. defmodule MyEndpoint do socket "/socket", MySocket # ... end

  27. defmodule MySocket do use Phoenix.Socket transport :websocket, Phoenix.Transports.WebSocket transport :longpoll,

    Phoenix.Transports.LongPoll channel "lobby", LobbyChannel channel "room:*", RoomChannel # ... end
  28. defmodule RoomChannel do use Phoenix.Channel def join(topic, payload, socket) do

    # ... end def handle_in(event, payload, socket) do # ... end def handle_info(erlang_message, socket) do # ... end end
  29. push(socket, event, payload) broadcast(socket, event, payload) broadcast_from(socket, event, payload)

  30. on_some_ui_event(() => channel.push("user_message", payload)) channel.on("user_message", (payload) => render(payload))

  31. defmodule RoomChannel do # ... def handle_in(event, payload, socket) do

    broadcast(socket, event, payload) # ... end # ... end
  32. conference program chat

  33. conference program chat ticket purchasing newsletters ratings raffles administration …

  34. start simple go far

  35. onboarding - getting started guides - Elixir - Phoenix -

  36. 40% off with code ctwwczg
 at manning.com https://joind.in/talk/60946