Astro.Supervisor (Astro v2.7.0)

Copy Markdown View Source

A supervisor for the time zone lookup Astro uses to report rise and set times in the local time zone of a location.

When :tz_world is a dependency and nothing else in the application starts its backend, add this supervisor to the application's supervision tree:

children = [
  Astro.Supervisor
]

Supervisor.start_link(children, strategy: :one_for_one)

An application can instead add TzWorld.Backend.SpatialIndex to its own tree, as the README describes.

Summary

Functions

Returns the specification to start Astro.Supervisor under another supervisor.

Starts the supervisor and, when :tz_world is a dependency, its TzWorld.Backend.SpatialIndex backend.

Functions

child_spec(options)

@spec child_spec(keyword()) :: Supervisor.child_spec()

Returns the specification to start Astro.Supervisor under another supervisor.

Arguments

  • options is a keyword list of options.

Options

  • There are none. options is accepted so the module can be listed as a child, and is otherwise ignored.

Returns

  • A child specification map.

Examples

iex> Astro.Supervisor.child_spec([])
%{id: Astro.Supervisor, start: {Astro.Supervisor, :start_link, []}, type: :supervisor}

start_link(type \\ [], args \\ [])

Starts the supervisor and, when :tz_world is a dependency, its TzWorld.Backend.SpatialIndex backend.

TzWorld.Backend.SpatialIndex is tz_world's recommended and default backend. It resolves a coordinate against an R-tree held in :persistent_term, without passing through a GenServer mailbox. The supervisor is registered as Astro.Supervisor.

Arguments

  • type and args are ignored.

Returns

  • {:ok, pid} once the supervisor and backend have started.

  • {:error, reason} if either could not be started.

Examples

In a script or a test helper that has no supervision tree:

{:ok, _pid} = Astro.Supervisor.start_link()