A signal (Visualize.Signals) as a feed: generated, pulled (spec/08 §11.6, D-140).
The feed's present tick is fixed (tick:, moved with at/2) or read from a clock
(every: milliseconds per tick). Its schema describes the first field, the tick, as
its window field — :number, since a tick is a count and not an instant, with
window: true and labelled "Tick" (spec/08 §10.1, D-154) — and every other field
:number, under whatever describe: adds. It honours :window: a window is ticks,
served up to the present tick, at most limit: rows and capped beyond. A budget is
left to visualize, and it does not push.
Examples
iex> signal = Visualize.Signals.new(:discrete, [:t, :n], window: 3)
iex> feed = Visualize.Feed.Signals.new(signal, tick: 10, describe: %{n: %{label: "Count"}})
iex> {_version, schema, [:window]} = Visualize.Feed.describe(feed)
iex> Visualize.Data.Schema.fetch(schema, :n, :label)
{:ok, "Count"}
iex> {:ok, delivery} = Visualize.Feed.fetch(feed, [4, 99], nil)
iex> {Enum.map(delivery.rows, & &1.t), delivery.window}
{[4, 5, 6, 7, 8, 9, 10], [4, 10]}
Summary
Functions
A ticked feed moved to a tick.
A signal as a feed. Options: describe: (descriptions merged over the defaults, field
by field), tick: (the present tick, 0), every: (milliseconds per tick, read from
clock: — a function of no argument in milliseconds, the monotonic clock by default —
counted from origin:, the clock now), and limit: (the most rows one fetch serves,
10_000). Raises ArgumentError for a description the schema refuses.
Types
@type t() :: %Visualize.Feed.Signals{ clock: (-> integer()) | nil, every: pos_integer() | nil, limit: pos_integer(), origin: integer(), schema: Visualize.Data.Schema.t(), signal: Visualize.Signals.t(), tick: non_neg_integer() }
Functions
@spec at(t(), non_neg_integer()) :: t()
A ticked feed moved to a tick.
@spec new(Visualize.Signals.t(), keyword()) :: t()
A signal as a feed. Options: describe: (descriptions merged over the defaults, field
by field), tick: (the present tick, 0), every: (milliseconds per tick, read from
clock: — a function of no argument in milliseconds, the monotonic clock by default —
counted from origin:, the clock now), and limit: (the most rows one fetch serves,
10_000). Raises ArgumentError for a description the schema refuses.