Packages

A configurable spherical geodesic grid data model designed for simulations GEOF Planet offers an ideal data model for simulations of 2½D spherical phenomena like oceanography and climate. It is ported from the JavaScript project g-e-o-f/peels.

Current section

Files

Jump to
geof_planet lib servers panel_supervisor.ex
Raw

lib/servers/panel_supervisor.ex

defmodule GEOF.Planet.PanelSupervisor do
@moduledoc """
Supervises `one_for_all` the PanelServers belonging to a SphereServer.
"""
use Supervisor
alias GEOF.Planet.Registry
# API
def start_link(sphere) do
Supervisor.start_link(__MODULE__, [sphere], name: Registry.panel_supervisor_via_reg(sphere.id))
end
# SERVER
@impl true
def init([sphere]) do
Supervisor.init(
init_children(sphere),
strategy: :one_for_all
)
end
defp init_children(sphere) do
Enum.map(
Map.keys(sphere.fields_at_panels),
fn panel_index ->
%{
id: {sphere.id, panel_index},
start: {
GEOF.Planet.PanelServer,
:start_link,
[sphere, panel_index]
}
}
end
)
end
end