Drone. Supervisor
(ex_drone v0.3.0)
View Source
Dynamic supervisor for drone vehicle processes.
Each drone is started as a child Drone.Vehicle process under this
supervisor. Processes are looked up by name via the Drone.Vehicle.Registry.
Prefer Drone.connect/2 / Drone.disconnect/1 over calling this module
directly unless you are embedding vehicles in a custom supervision tree.
Examples
{:ok, _pid} = Drone.Supervisor.start_link([])
{:ok, _vehicle} =
Drone.Supervisor.start_vehicle(
name: :alpha,
adapter: :sim
)
:ok = Drone.Supervisor.stop_vehicle(:alpha)
Summary
Functions
Returns a specification to start this module under a supervisor.
Starts the dynamic supervisor (named Drone.Supervisor).
Starts a Drone.Vehicle child under this supervisor.
Terminates the vehicle registered under name.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec start_link(keyword()) :: GenServer.on_start()
Starts the dynamic supervisor (named Drone.Supervisor).
Parameters
opts(keyword()) — forwarded toDynamicSupervisor.start_link/3(usually empty; the process is registered as__MODULE__)
Returns
GenServer.on_start().
Examples
{:ok, _pid} = Drone.Supervisor.start_link([])
@spec start_vehicle(keyword()) :: Supervisor.on_start_child()
Starts a Drone.Vehicle child under this supervisor.
Parameters
opts(keyword()) — same options asDrone.Vehicle.start_link/1(:name,:adapter,:safety, plus adapter opts)
Returns
Supervisor.on_start_child() ({:ok, pid} \| {:error, reason}).
Examples
{:ok, _pid} =
Drone.Supervisor.start_vehicle(
name: :sim_1,
adapter: :sim,
battery: 100
)
@spec stop_vehicle(atom()) :: :ok | {:error, :not_found}
Terminates the vehicle registered under name.
Parameters
name(atom()) — vehicle name fromstart_vehicle/1
Returns
:ok— child terminated{:error, :not_found}— no process registered under that name
Examples
:ok = Drone.Supervisor.stop_vehicle(:sim_1)
{:error, :not_found} = Drone.Supervisor.stop_vehicle(:missing)