Macaw.Live.Reader (macaw_live v0.1.0)

Copy Markdown View Source

macaw's Macaw.Surface.Reader over the host's source managers (spec/03 §9, macaw#443): how a socketless render (Macaw.Surface.fetch/2), Macaw.Surface.legal/2 and Macaw.Page.check/3 read a source from the manager that holds it, so a request reads a source once and the connected mount after it finds the manager warm.

A host gives it as manager: Macaw.Live.reader(live, sources) in each env; macaw_live's own socketless render passes it. Its argument is this struct: the supervisor's name, the host's sources:, the names of the sources that declare themselves viewer_independent (any other is read per viewer), and the bound of its wait, timeout:.

  • window/3 reads the request's window from the source's manager (key/4's), started when none runs: a window it holds already is read at once; otherwise the caller subscribes it, waits up to timeout: for the manager to say it is held, reads it, and unsubscribes. {:ok, delivery}, finished for the request; :loading for a window not held in time; {:error, reason} for a source down, unknown or refused.
  • distinct/4 reads the whole source the same way and answers the field's distinct present values, each spelled as Macaw.Surface.Reader.spelled/1 spells it.

Both run in the caller and never call a manager: they read its table (Macaw.Data.Manager.Reader).

Summary

Functions

A reader over the managers of the supervisor live, for the host's sources:. opts: independent: the names of the sources declaring themselves viewer_independent; timeout: (5,000 ms) the bound of each wait; clock:, tick: and stale_after:, the settings a manager it starts takes.

The managers of readers, Macaw.Surface.readers/2's, subscribed at once, so a render reading them one after another waits for the slowest, not their sum: :ok.

Types

t()

@type t() :: %Macaw.Live.Reader{
  env: keyword(),
  independent: MapSet.t(),
  live: atom(),
  sources: map(),
  timeout: non_neg_integer()
}

Functions

new(live, sources, opts \\ [])

@spec new(atom(), map(), keyword()) :: t()

A reader over the managers of the supervisor live, for the host's sources:. opts: independent: the names of the sources declaring themselves viewer_independent; timeout: (5,000 ms) the bound of each wait; clock:, tick: and stale_after:, the settings a manager it starts takes.

prefetch(reader, readers)

@spec prefetch(t(), [map()]) :: :ok

The managers of readers, Macaw.Surface.readers/2's, subscribed at once, so a render reading them one after another waits for the slowest, not their sum: :ok.