VerifiedPubSub.Info (VerifiedPubSub v0.1.0)

Copy Markdown View Source

The only supported way to read a manifest.

Read a manifest through these functions, not through the Spark internals, so that the DSL stays replaceable.

Summary

Functions

Returns the events that a topic declares, in the order of declaration.

Returns the fields that an event declares, in the order of declaration.

Finds the declared topic that a wire topic belongs to, and the params that it carries.

Returns the params of a topic, in the order of its segments.

Fetches a topic by its name.

Fetches a topic by its name, and raises with the known topics when it is absent.

topics DSL entities

Functions

events(manifest, name)

@spec events(module(), atom()) :: [atom()]

Returns the events that a topic declares, in the order of declaration.

fields(manifest, topic, event)

@spec fields(module(), atom(), atom()) :: [VerifiedPubSub.Dsl.Field.t()]

Returns the fields that an event declares, in the order of declaration.

match(manifest, wire)

@spec match(module(), String.t()) ::
  {:ok, atom(), %{required(atom()) => String.t()}} | :error

Finds the declared topic that a wire topic belongs to, and the params that it carries.

iex> VerifiedPubSub.Info.match(MyApp.Topics, "owners:42:pets")
{:ok, :pets, %{owner_id: "42"}}

It does the reverse of VerifiedPubSub.Api.topic/2, for a string from a log, a trace, or Phoenix.PubSub. Param values come back as the strings that were on the wire. Returns :error when no topic matches, and when a param segment is empty, which no broadcast can produce.

params(manifest, name)

@spec params(module(), atom()) :: [atom()]

Returns the params of a topic, in the order of its segments.

topic(manifest, name)

@spec topic(module(), atom()) :: {:ok, VerifiedPubSub.Dsl.Topic.t()} | :error

Fetches a topic by its name.

topic!(manifest, name)

@spec topic!(module(), atom()) :: VerifiedPubSub.Dsl.Topic.t()

Fetches a topic by its name, and raises with the known topics when it is absent.

topics(dsl_or_extended)

@spec topics(dsl_or_extended :: module() | map()) :: [struct()]

topics DSL entities