A source manager's reader (spec/06 §3.5, spec/07 §2.2, #443): how a host lets the paths
outside a live page, Macaw.Surface.fetch/2 (and so render/2, show/2 and a
container's surfaces), Macaw.Surface.legal/2 and Macaw.Page.check/3, read a source's
data from the manager that holds it rather than from its adapter.
A host gives one as manager: {module, arg} in each env, module implementing this
behavior and arg the term each callback is given first (the host's managers, the
viewer's, a registry name: macaw never reads it). Without manager: (or with nil), each
path calls the host's sources as it always has.
window/3answers a reader's window of a source: the delivery the source itself would answer the request, before finishing.fetch/2asks it once per pooled request (one per source and request equal but for the budget, at the largest budget) and packs, finishes and reduces what it answers as it does a fetch's, so the cells draw exactly as they would from the source.distinct/4answers a field's distinct present values as aMapSet, each spelled asspelled/1spells it (a category's by its spelling): the legal values of avalues_fromparam or state.legal/2andcheck/3ask it once per{source, field}per call, and only for a field whose schema declares novalues, which are answered from the schema with no read.
Each callback runs in the caller's process, never bounded by timeout:: a manager's
reader reads what its manager has published and never waits on an adapter, so bounding
its own wait is the reader's, answering :loading (a window not held in time) or an
error. An error is a value: a window's {:error, reason} draws its cells down, as a
fetch's error does, and a distinct's is the check's {:unavailable, reason}.
Summary
Callbacks
A window of the source named source, as request asks it (its params, window, box,
as_of, order, budget, viewer and now): {:ok, delivery}, the delivery the source would
answer; :loading, a window the manager doesn't hold within its own bound, drawn
loading; or {:error, reason}, drawn down.
Functions
A value as a legal check compares it, the spelling distinct/4's values are in: an
atom naming a category by its string, any other value as it is at the edge.
Types
Callbacks
@callback distinct( arg :: term(), source :: String.t(), field :: String.t(), Macaw.Data.Source.Request.t() ) :: {:ok, MapSet.t()} | {:error, term()}
The distinct present values of field of the source named source, as request reads
it (its viewer and now): {:ok, set}, a MapSet of the values, each spelled as
spelled/1 spells it, nil never among them; or {:error, reason}, a check that can't
be made, {:unavailable, reason}.
@callback window( arg :: term(), source :: String.t(), request :: Macaw.Data.Source.Request.t() ) :: {:ok, Macaw.Data.Delivery.t()} | :loading | {:error, term()}
A window of the source named source, as request asks it (its params, window, box,
as_of, order, budget, viewer and now): {:ok, delivery}, the delivery the source would
answer; :loading, a window the manager doesn't hold within its own bound, drawn
loading; or {:error, reason}, drawn down.
Functions
A value as a legal check compares it, the spelling distinct/4's values are in: an
atom naming a category by its string, any other value as it is at the edge.
iex> Macaw.Surface.Reader.spelled(:api)
"api"
iex> Macaw.Surface.Reader.spelled(3)
3