Spex.InstanceManager.Instance (spex v0.1.0)

Copy Markdown View Source

Runtime representation of a specification instance and its observed history.

Summary

Functions

Returns whether the instance exceeded its specification transition timeout.

Initialises a new instance with an empty transition history.

Records an observed transition and updates the current state.

Returns whether the instance is currently eligible for pruning.

Types

instance_identifier()

@type instance_identifier() :: term()

meta()

@type meta() :: map()

t()

@type t() :: %Spex.InstanceManager.Instance{
  current_state: Spex.state() | nil,
  identifier: instance_identifier(),
  meta: meta() | nil,
  specification: Spex.Specification.t(),
  transitions: [transition_record()]
}

transition_record()

@type transition_record() ::
  {action :: Spex.action(), to_state :: Spex.state(), timestamp :: DateTime.t()}

Functions

beyond_transition_timeout?(instance, now \\ DateTime.utc_now())

@spec beyond_transition_timeout?(t(), DateTime.t()) :: boolean()

Returns whether the instance exceeded its specification transition timeout.

initialise(specification, identifier, meta)

@spec initialise(Spex.Specification.t(), instance_identifier(), meta() | nil) :: t()

Initialises a new instance with an empty transition history.

observe_transition(instance, action, to_state)

@spec observe_transition(t(), Spex.action(), Spex.state()) :: t()

Records an observed transition and updates the current state.

prunable?(instance)

@spec prunable?(t()) :: boolean()

Returns whether the instance is currently eligible for pruning.