Steward.Resource (Steward v0.1.0)

Copy Markdown View Source

A resource object, the unit of reconciliation.

A resource belongs to a controller (see Steward.Controller) and typically corresponds to a domain entity, e.g. an order. Steward reconciles each resource's jobs separately, against the spec its controller's workers compute for it.

Create resources with Steward.Controller.create_resource/3, and manage them with the other functions in Steward.Controller.

Fields

  • :controller - the name of the resource's controller module.
  • :id - the resource's UUID, unique per controller. Generated unless given on creation.
  • :meta - a map of arbitrary domain information, e.g. foreign keys, see Steward.Controller.list_resources_by_meta/2. Stored as JSON.
  • :object - virtual field holding the domain data loaded by Steward.Controller.load/1. Not persisted.
  • :cancelled_at - when the resource was cancelled, see Steward.Controller.cancel_resource!/2.
  • :pruned_at - when the jobs of the cancelled resource were deleted, see the :prune_max_age option of Steward.Plugin.
  • :reconciliation_state - :idle, :scheduled (due at :reconciliation_due_at) or :reconciling, set at :reconciliation_state_set_at.
  • :reconciliation_error - the error of the last failed reconciliation, if any. Cleared when the resource is reconciled again.

Steward manages all fields but :meta and :object. Don't change them yourself.

Summary

Functions

Returns whether the resource is cancelled, see Steward.Controller.cancel_resource!/2.

Returns whether the jobs of the cancelled resource were pruned, see the :prune_max_age option of Steward.Plugin.

Types

id()

(since 0.1.0)
@type id() :: binary()

t()

(since 0.1.0)
@type t() :: %Steward.Resource{
  __meta__: term(),
  cancelled_at: term(),
  controller: term(),
  id: term(),
  inserted_at: term(),
  meta: term(),
  object: term(),
  pruned_at: term(),
  reconciliation_due_at: term(),
  reconciliation_error: term(),
  reconciliation_state: term(),
  reconciliation_state_set_at: term(),
  updated_at: term()
}

Functions

cancelled?(resource)

(since 0.1.0)
@spec cancelled?(t()) :: boolean()

Returns whether the resource is cancelled, see Steward.Controller.cancel_resource!/2.

pruned?(resource)

(since 0.1.0)
@spec pruned?(t()) :: boolean()

Returns whether the jobs of the cancelled resource were pruned, see the :prune_max_age option of Steward.Plugin.