Macaw.Data.Manager.Supervisor (macaw_data v0.21.1)
View SourceThe source managers' supervisor (spec/01 §6.4.6, #461): everything a host's source managers run under. Moved from macaw_live's supervisor with the managers (dco-tek/macaw/macaw#478 decision 6a, #450), so a headless pipeline runs a named source's manager with no macaw_live.
The library starts no process of its own. A host adds one, names it, and passes the
name wherever a manager is used (Macaw.Data.Manager.ensure/3, lookup/2,
Macaw.Data.Manager.Reader.read/3):
children = [{Macaw.Data.Manager.Supervisor, name: MyApp.Managers}]Its children, :one_for_one, each named from the name given (child/2):
<name>.Registry, aRegistryof unique keys: each manager under{:manager, key}with its table. Its meta holds the options every manager reads:memory,detectors,notify,topicandtold?. Nothing is held anywhere else, so two supervisors never share a manager, a budget or an option;<name>.Managers, aDynamicSupervisorof the managers,:transient;<name>.Tasks, aTask.Supervisorof the managers' turns (spec/01 §6.4.6);<name>.Tables, the heir of every manager's table, which keeps it a grace past the manager's end, and the owner of the memory budget's table,<name>.Budget.
Summary
Types
What start_link/1 answers for options it can't use.
Functions
The name of one of the supervisor's children, derived from its name: :registry,
:managers, :tasks, :tables, or :budget, the budget's table.
Its child spec, for a host's tree: a supervisor, its id the name given.
One of the options the supervisor name was started with, as every manager reads it:
:memory, :detectors, :notify, :topic or :told?, its default when not given.
Starts the supervisor: {:ok, pid}, or {:error, faults} with every fault of its
options at once, by key. Options
Types
@type fault() :: Macaw.Base.Fault.t()
What start_link/1 answers for options it can't use.
Functions
The name of one of the supervisor's children, derived from its name: :registry,
:managers, :tasks, :tables, or :budget, the budget's table.
iex> Macaw.Data.Manager.Supervisor.child(MyApp.Managers, :registry)
MyApp.Managers.Registry
iex> Macaw.Data.Manager.Supervisor.child(MyApp.Managers, :managers)
MyApp.Managers.Managers
iex> Macaw.Data.Manager.Supervisor.child(MyApp.Managers, :tasks)
MyApp.Managers.Tasks
iex> Macaw.Data.Manager.Supervisor.child(MyApp.Managers, :tables)
MyApp.Managers.Tables
iex> Macaw.Data.Manager.Supervisor.child(MyApp.Managers, :budget)
MyApp.Managers.Budget
@spec child_spec(keyword()) :: Supervisor.child_spec()
Its child spec, for a host's tree: a supervisor, its id the name given.
One of the options the supervisor name was started with, as every manager reads it:
:memory, :detectors, :notify, :topic or :told?, its default when not given.
Starts the supervisor: {:ok, pid}, or {:error, faults} with every fault of its
options at once, by key. Options:
name:, required, an atom: its registered name, every child's derived from it;memory:, the bytes the managers may hold together (spec/01 §6.4.6), a positive integer,nil(no budget) by default;detectors:, a source's name to its change detector (spec/01 §5):{module, opts}or{module, opts, every: ms}of a module implementingMacaw.Data.Source.Detector,%{}by default;notify:, the change transport a manager subscribes through,{module, arg}of a loaded module exportingsubscribe/2(module.subscribe(arg, topic)),nil(none) by default; andtopic:, a function of a source's name to its topic there, required withnotify:. A manager subscribes, when it starts, to its source's topic, and a change notice is{:macaw_data, :changed, name, what}on it;told?:, a function of a source's entry to whether its owner tells its manager when it has an answer (a derived output's), so a read it answered{:error, :loading}waits for that notice rather than drawing its readers down, and it is never polled;fn _ -> false endby default;grace:, how long a manager's table outlives it, 60,000 ms by default.
Faults: {[:name], :required}, {[:name], {:type, :atom}}, {[key], :unknown_key},
{[:memory], {:type, :pos_integer}}, {[:detectors], {:type, :map}},
{[:detectors, name], {:type, Macaw.Data.Source.Detector}}, {[:notify], {:type, :notify}}, {[:topic], {:type, :function}} ({[:topic], :required} with a notify:),
{[:told?], {:type, :function}} and {[:grace], {:type, :non_neg_integer}}. Options
that aren't a keyword list are {[], {:type, :keyword}}.