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

Saša Jurić

October 25, 2013
Tweet

More Decks by Saša Jurić

Other Decks in Programming

Transcript

  1. 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
  2. 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
  3. 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
  4. -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}.
  5. 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
  6. 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
  7. 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
  8. 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)