Macaw.Data.Source.Change (macaw_data v0.21.1)

View Source

A change notice: a source's name and what changed (spec/01 §5.1, dco-tek/macaw/macaw#108), so a reader re-reads only that.

what is {:range, from, to}, the window field's values from from up to but not including to, either nil for open, as a range replacement's (spec/01 §4.2); {:identities, ids}, the rows of those identities wherever they lie; or :all. concerns?/2 says, without I/O, whether a notice concerns a reader's request or window.

iex> alias Macaw.Data.Source.Change
iex> {:ok, change} = Change.new(:services, {:range, 10, 20})
iex> Change.concerns?(change, [15, 40])
true
iex> Change.concerns?(change, [20, 40])
false
iex> Change.concerns?(change, {:hosts, [15, 40]})
false
iex> Change.new(:services, {:range, 20, 10})
{:error, [{[:what], {:window, :inverted}}]}

Summary

Types

t()

What changed: a range of the window field, identities, or everything.

Functions

A notice that everything of source changed.

Whether the notice concerns a reader: subject a Source.Request, a window (nil for everything, or [from, to], both ends inclusive, either nil for open), or {source, request_or_window}, which a notice for another source never concerns. :all and identities concern every reader of the source; a range concerns a window it meets, compared by instant whatever the kinds of time.

A notice that the rows of ids changed, wherever they lie.

A notice that what of source changed: {:ok, change}, or every fault at once. A range whose ends are not both times or both numbers (an open end aside) is {[:what], {:type, :range}}, one whose from is after its to {[:what], {:window, :inverted}}; identities that are no list {[:what], {:type, :identities}}; any other what {[:what], {:type, :what}}.

A notice that [from, to) of source's window field changed, unchecked.

Types

t()

@type t() :: %Macaw.Data.Source.Change{source: term(), what: what()}

what()

@type what() :: {:range, term(), term()} | {:identities, list()} | :all

What changed: a range of the window field, identities, or everything.

Functions

all(source)

@spec all(term()) :: t()

A notice that everything of source changed.

concerns?(change, arg2)

@spec concerns?(t(), term()) :: boolean()

Whether the notice concerns a reader: subject a Source.Request, a window (nil for everything, or [from, to], both ends inclusive, either nil for open), or {source, request_or_window}, which a notice for another source never concerns. :all and identities concern every reader of the source; a range concerns a window it meets, compared by instant whatever the kinds of time.

identities(source, ids)

@spec identities(term(), list()) :: t()

A notice that the rows of ids changed, wherever they lie.

new(source, what)

@spec new(term(), term()) :: {:ok, t()} | {:error, [{list(), term()}, ...]}

A notice that what of source changed: {:ok, change}, or every fault at once. A range whose ends are not both times or both numbers (an open end aside) is {[:what], {:type, :range}}, one whose from is after its to {[:what], {:window, :inverted}}; identities that are no list {[:what], {:type, :identities}}; any other what {[:what], {:type, :what}}.

range(source, from, to)

@spec range(term(), term(), term()) :: t()

A notice that [from, to) of source's window field changed, unchecked.