Routemaster Client v0.3.0 Routemaster.Publisher.Event View Source

An event to be published to the bus.

This is not defined as a struct because we do not want missing values to default to nil. With a struct, in fact, missing fields would still be present with their keys pointing to nil values, and the generated JSON would be larger.

Fields

  • type, e.g. created, updated.
  • url, the canonical URL where the resource can be found.
  • timestamp, time of the event (optional).
  • data, a payload (optional).

See Routemaster.Drain.Event for the incoming events.

Link to this section Summary

Functions

Builds a compact Map from the four event attributes, ignoring nil data values. The timestamp is always set

Validates that the event map is complete and correct. It raises a Routemaster.Publisher.Event.ValidationError exception if the map is invalid

Link to this section Types

Link to this type t() View Source
t() :: %{
  :type => type(),
  :url => url(),
  :timestamp => timestamp(),
  optional(:data) => data()
}

Link to this section Functions

Link to this function build(type, url, timestamp, data) View Source
build(type(), url(), timestamp() | nil, data() | nil) :: t()

Builds a compact Map from the four event attributes, ignoring nil data values. The timestamp is always set.

Link to this function validate!(event) View Source
validate!(t()) :: nil

Validates that the event map is complete and correct. It raises a Routemaster.Publisher.Event.ValidationError exception if the map is invalid.