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

Elixir, Erlang, i visoko dostupni serverski sustavi

Elixir, Erlang, i visoko dostupni serverski sustavi

WebCampZg 2013

78d85ea26770975ea8c497d7bd722d55?s=128

Saša Jurić

October 25, 2013
Tweet

Transcript

  1. Elixir, Erlang i visoko dostupni serverski sustavi @sasajuric

  2. Tko vrijedi, je dostupan. Tko je dostupan, vrijedi. Tko nije

    dostupan, ne vrijedi.
  3. None
  4. EVM Erlang stdlib OTP Erlang programi Erlang/OTP

  5. dostupnost stabilnost skalabilnost distribuiranost responzivnost live upgrade concurrency dostupnost

  6. P P P P P P P P P P

    P P P P P P P P P P P scheduler scheduler scheduler scheduler CPU CPU CPU CPU EVM
  7. P P P P exit signal vrijeme P'

  8. P P P P P P P P P P

    P P P P P P P P P P P scheduler scheduler scheduler scheduler CPU CPU CPU CPU EVM
  9. EVM P P P P P P P P P

    P P P P P P P P P P P P scheduler scheduler scheduler scheduler CPU CPU CPU CPU EVM
  10. scheduler scheduler scheduler scheduler listener request request job 1 job

    2 request EVM
  11. EVM Erlang stdlib OTP Erlang programi :-) :-(

  12. EVM Erlang stdlib OTP Erlang programi Elixir Elixir programi

  13. -module(sum_actor). -behaviour(gen_server). -export([ start/0, sum/3, init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2,

    code_change/3 ]). start() -> gen_server:start(?MODULE, [], []). sum(Server, A, B) -> gen_server:call(Server, {sum, A, B}). init(_) -> {ok, undefined}. handle_call({sum, A, B}, _From, State) -> {reply, A+B, State}; handle_call(_Request, _From, State) -> {reply, error, State}. handle_cast(_Msg, State) -> {noreply, State}. handle_info(_Info, State) -> {noreply, State}. terminate(_Reason, _State) -> ok. code_change(_OldVsn, State, _Extra) -> {ok, State}.
  14. defmodule SumActor do use GenServer.Behaviour def start do :gen_server.start(__MODULE__, [],

    []) end def sum(server, a, b) do :gen_server.call(server, {:sum, a, b}) end def handle_call({:sum, a, b}, _from, state) do {:reply, a + b, state} end end
  15. defmodule SumActor do use ExActor defcall sum(a, b) do a

    + b end end
  16. defcall sum(a, b) do a + b end def sum(server,

    a, b) do :gen_server.call(server, {:sum, a, b}) end def handle_call({:sum, a, b}, _from, state) do {:reply, a + b, state} end
  17. Repo.all( from w in Weather, where: w.prcp > 0 or

    w.prcp == nil, select: w ) get "/hello/world" do conn.resp(200, "Hello world") end fact "addition" do 1 + 1 |> 2 end
  18. obradi_xml(Model, Xml) -> Model1 = azuriraj(Model, Xml), Model2 = obradi_promjene(Model1),

    pohrani(Model2).
  19. obradi_xml(Model, Xml) -> Model1 = azuriraj(Model, Xml), Model2 = obradi_promjene(Model1),

    pohrani(Model2).
  20. def obradi_xml(model, xml) do model |> azuriraj(xml) |> obradi_promjene |>

    pohrani end f(...) |> g(...) g(f(...), ...)
  21. defrecord Person, [:name, :age] record = MyRecord.new(name: "Saša Jurić") record

    = record.age(36) x = 5 IO.puts "#{x} * #{x} = #{x * x}" String.codepoints("Saša Jurić") sasa: ~$ mix new test * creating README.md * creating .gitignore * creating mix.exs * creating lib * creating lib/test.ex * creating test * creating test/test_helper.exs * creating test/test_test.exs Enum.each(enumerable, ...) inspect(inspectable)
  22. elixir-lang.org elixir-lang-talk elixir-lang-core Hacking Devin Torres A Cauldron of Black

    and White Stones The Erlangelist