The Multi-Snake project was created to support the talk Processes & Grains A Journey in Orleans at Code BEAM Europe 2022 on 19 May 2022.
A copy of the deck can be found here.
A deployed version on Fly.io is available at https://snake-web.fly.dev.
To run the code:
.tool-versions
).mix deps.get
.mix ecto.setup
../bin/run
.https://localhost:4000
../bin/console
.The Multi-Snake application is an umbrella application with the following applications:
snake
: Holds the core game logic and backends.snake_data
: Holds Ecto Repo and all migrations.snake_environment
: Holds clustering and endpoint configuration logic.snake_proxy
: Holds a connection proxy allowing numerous Phoenix apps to be hooked.snake_web
: Holds the main Web application containing a LiveView interface.Within apps/snake/config/config.exs
, the appropriate Backend can be selected:
config :snake,
backend_module: Snake.Game.Backend.HordeStatem
Where 3 distinct backends are available:
Snake.Game.Backend.ErleansGrain
, implemented as a stateful Erleans Grain, preferring local activation.
Snake.Game.Backend.HordeServer
, implemented as a GenServer registered under a distributed supervisor offered by Horde.
Snake.Game.Backend.HordeStatem
, implemented as a GenStateMachine (Elixir wrapper of gen_statem) registered under a distributed supervisor offered by Horde.
Via Prepared Script:
$ flyctl ssh console
> /app/migrate.sh