Visualize.Feed.Combine (Visualize v0.4.0)

Copy Markdown View Source

One feed over several, routed by window: live data and its history in one slot (spec/08 §11.5, D-140).

The feeds are listed freshest first — say an in-process :telemetry feed holding the last hour, then a metresis feed holding everything. A fetch asks the first for the window; what it served starts at its delivery's window (else its earliest row), and the part of the window before that goes to the next feed, and so on. Each later feed's rows are trimmed to the half-open window it was asked for, [from, served), so a row at a seam comes from the fresher feed alone. Every feed must describe the same schema, since a delivery names one version, and the schema must have a window field to route by, :time or :number (spec/08 §11.2, D-154); choosing the feeds and making their schemas agree is the connector's.

A combination honours :window, and pushes when its first feed does: its pushes name the shared version and pass through unchanged. A budget is passed to every part as a request and left to the monitor.

Examples

iex> alias Visualize.Feed.Signals
iex> signal = Visualize.Signals.new(:discrete, [:t, :n])
iex> live = Signals.new(signal, tick: 9, limit: 3)
iex> history = Signals.new(signal, tick: 9)
iex> {:ok, delivery} = Visualize.Feed.fetch(Visualize.Feed.Combine.new([live, history]), [2, 9], nil)
iex> {Enum.map(delivery.rows, & &1.t), delivery.window, delivery.capped}
{[2, 3, 4, 5, 6, 7, 8, 9], [2, 9], false}

Summary

Functions

The shared {version, schema, supports}: {:error, {:combine_schema, versions}} when the feeds describe different schemas, {:error, :combine_window_field} when the schema has no window field, and the first error of a feed that cannot describe.

One feed over several, freshest first.

Types

t()

@type t() :: %Visualize.Feed.Combine{feeds: [Visualize.Feed.t(), ...]}

Functions

describe(combine)

The shared {version, schema, supports}: {:error, {:combine_schema, versions}} when the feeds describe different schemas, {:error, :combine_window_field} when the schema has no window field, and the first error of a feed that cannot describe.

new(feeds)

@spec new([Visualize.Feed.t(), ...]) :: t()

One feed over several, freshest first.