Allows you to create servers which implement the Maelstrom protocol.
Maelstrom is a workbench for learning distributed systems by writing your own.
- Documentation: https://hexdocs.pm/maelstrom
- Package details on hex: https://hex.pm/maelstrom
To implement a server:
- Create a module and
use Maelstrom
- Implement one or more
handle_message
heads. - Call
MyModule.run_forever()
.
I recommend you do this in a .exs script. Example:
defmodule Echo do
use Maelstrom
def handle_message(_src, _dest, %{"echo" => echo}, state, _) do
{:reply, %{"type" => "echo_ok", "echo" => echo}, state}
end
end
Echo.run_forever()
You could then run this with mix run
e.g. mix run echo.exs
.
Maelstrom expects a single binary with no arguments to call for testing. In order to accomplish this, wrap your mix run command in a shell script (see demos for examples).
For more examples, see demos.