Macaw.Live.Manager.Read (macaw_live v0.1.0)

Copy Markdown View Source

A reader's read of its window, as the page holds it (spec/03 §2.2, dco-tek/macaw/macaw#108 "Readers hold no chunks"): what it read and how it drew, never the rows. A page holds this in a cell's entry where it held the delivery; the process that draws the cell (a proof, a contained cell) reads the window again from the manager's table with resolve/1, and drops it when its work is done.

  • live and key: the supervisor and the manager whose table holds the window;
  • request: the reader's request, finished for it alone, and clamped, whether the ceiling cut its budget (the delivery then says reduced_by: :runtime);
  • overlay: the visitor's overlay of the source it was read through (Macaw.Live.Manager.Reader.read/4, macaw spec/13 §3.4), nil for none;
  • status: the manager's status the read was made at, and drawn, the slot's drawn state from it and the delivery (Macaw.Surface.drawn/2);
  • signature: the window's chunks as the delivery held them, each {id, version, first, count} (a version is its content's digest), with its size, sort and served facts: two reads of one signature resolve to the same delivery.

Equal reads draw alike, so change detection ("an unchanged component sends nothing") and the render memo's key compare reads, never data.

Summary

Functions

A read of a table delivery the reader's window answered, through the visitor's overlay (nil for none): its status, drawn state and chunk signature kept, the delivery itself not.

The read's window read again from its manager's table, finished for its request, through its overlay, and clamped as it was: {:ok, delivery}, the delivery its signature names; {:moved, delivery}, the window as its manager publishes it now, when that has moved since the read (its page told and reading it again); or :gone when the table no longer holds it (its manager restarted, its slots evicted). A delivery given is its own.

Each slot's read resolved (resolve/1): {deliveries, exact?}, the deliveries of the slots whose windows were read, and whether every slot resolved to the delivery its read names (none moved or gone).

Types

t()

@type t() :: %Macaw.Live.Manager.Read{
  clamped: boolean(),
  drawn: atom(),
  key: Macaw.Data.Manager.key(),
  live: atom(),
  overlay: Macaw.Live.Manager.Reader.overlay() | nil,
  request: Macaw.Data.Source.Request.t(),
  signature: term(),
  status: Macaw.Data.Manager.status()
}

Functions

of(live, key, request, clamped, status, delivery, overlay \\ nil)

A read of a table delivery the reader's window answered, through the visitor's overlay (nil for none): its status, drawn state and chunk signature kept, the delivery itself not.

resolve(delivery)

@spec resolve(t() | Macaw.Data.Delivery.t()) ::
  {:ok | :moved, Macaw.Data.Delivery.t()} | :gone

The read's window read again from its manager's table, finished for its request, through its overlay, and clamped as it was: {:ok, delivery}, the delivery its signature names; {:moved, delivery}, the window as its manager publishes it now, when that has moved since the read (its page told and reading it again); or :gone when the table no longer holds it (its manager restarted, its slots evicted). A delivery given is its own.

resolve_all(reads)

@spec resolve_all(%{required(String.t()) => t() | Macaw.Data.Delivery.t()}) ::
  {map(), boolean()}

Each slot's read resolved (resolve/1): {deliveries, exact?}, the deliveries of the slots whose windows were read, and whether every slot resolved to the delivery its read names (none moved or gone).