Victoria.Model behaviour (Victoria v0.2.0)

Copy Markdown View Source

Defines the implementation lifecycle used while replaying a trace.

The implementation value is opaque to Victoria. It may be a value, PID, database context, client, or any other implementation handle. State zero is passed to init/1 and verified without being executed. Later steps are passed to execute/2, then compared through snapshot/1 and project/1. Optional cleanup/1 runs once after a successful init on every controlled exit.

Summary

Types

Opaque implementation state owned by the model.

A model-defined callback failure reason.

Callbacks

Releases implementation resources after a controlled replay exit.

Executes one non-initial formal step and returns the next implementation handle.

Creates the implementation from the initial formal state.

Returns the expected state supplied by a formal step.

Returns the implementation's observed state.

Types

implementation()

@type implementation() :: term()

Opaque implementation state owned by the model.

reason()

@type reason() :: term()

A model-defined callback failure reason.

Callbacks

cleanup(implementation)

(optional)
@callback cleanup(implementation()) :: :ok | {:error, reason()}

Releases implementation resources after a controlled replay exit.

execute(t, implementation)

@callback execute(Victoria.Step.t(), implementation()) ::
  {:ok, implementation()} | {:error, reason()}

Executes one non-initial formal step and returns the next implementation handle.

init(map)

@callback init(map()) :: {:ok, implementation()} | {:error, reason()}

Creates the implementation from the initial formal state.

project(t)

@callback project(Victoria.Step.t()) :: map()

Returns the expected state supplied by a formal step.

snapshot(implementation)

@callback snapshot(implementation()) :: map()

Returns the implementation's observed state.