Erlang's gen_server is already a pretty simple way to implement a server behaviour. Elixir's GenServer.Behaviour takes that and makes it even simpler, by providing sane default implementations of the gen_server callback functions. But there's a library called ExActor that takes it one step further. Let's have a look at how it simplifies the creation of servers to its logical conclusion.

Let's go ahead and start a new project: mix new exactor_test; cd exactor_test. The first thing we need to do is add ExActor to the deps, so open up mix.exs and make the deps look like the following:

 defp deps do [ { :exactor, github: "sasa1977/exactor" } ] end

Then fetch it with mix deps.get.

Now open up the test/exactor_test_test.exs file and let's start building out a test to try this thing out.

defmodule ExactorTestTest do use ExUnit.Case test "a basic actor" do {:ok, list} = ListActor.start([]) assert ListActor.get(list) == [] :ok =...