Sprites.Checkpoint (Sprites v0.2.0)

View Source

Checkpoint management for sprites.

Checkpoints allow you to save and restore the state of a sprite.

Summary

Functions

Represents a checkpoint.

Creates a new checkpoint for a sprite.

Creates a new checkpoint for a sprite by name.

Creates a checkpoint from a map.

Gets a specific checkpoint by ID.

Gets a specific checkpoint by sprite name and checkpoint ID.

Lists all checkpoints for a sprite.

Lists all checkpoints for a sprite by name.

Restores a sprite from a checkpoint.

Restores a sprite from a checkpoint by name.

Types

t()

@type t() :: %Sprites.Checkpoint{
  comment: String.t() | nil,
  create_time: DateTime.t() | nil,
  history: [String.t()],
  id: String.t()
}

Functions

%Sprites.Checkpoint{}

(struct)

Represents a checkpoint.

Fields

  • :id - Unique checkpoint identifier
  • :create_time - When the checkpoint was created (DateTime)
  • :history - List of parent checkpoint IDs
  • :comment - Optional user-provided comment

create(sprite, opts \\ [])

@spec create(
  Sprites.Sprite.t(),
  keyword()
) :: {:ok, Enumerable.t()} | {:error, term()}

Creates a new checkpoint for a sprite.

Returns a stream of messages. The stream should be consumed to completion.

Options

  • :comment - Optional comment for the checkpoint

Examples

{:ok, stream} = Sprites.Checkpoint.create(sprite, comment: "Before changes")
Enum.each(stream, fn msg -> IO.inspect(msg) end)

create_by_name(client, name, opts \\ [])

@spec create_by_name(Sprites.Client.t(), String.t(), keyword()) ::
  {:ok, Enumerable.t()} | {:error, term()}

Creates a new checkpoint for a sprite by name.

from_map(map)

@spec from_map(map()) :: t()

Creates a checkpoint from a map.

get(sprite, checkpoint_id)

@spec get(Sprites.Sprite.t(), String.t()) :: {:ok, t()} | {:error, term()}

Gets a specific checkpoint by ID.

Examples

{:ok, checkpoint} = Sprites.Checkpoint.get(sprite, "checkpoint-id")

get_by_name(client, name, checkpoint_id)

@spec get_by_name(Sprites.Client.t(), String.t(), String.t()) ::
  {:ok, t()} | {:error, term()}

Gets a specific checkpoint by sprite name and checkpoint ID.

list(sprite, opts \\ [])

@spec list(
  Sprites.Sprite.t(),
  keyword()
) :: {:ok, [t()]} | {:error, term()}

Lists all checkpoints for a sprite.

Options

  • :history - History filter string (optional)

Examples

{:ok, checkpoints} = Sprites.Checkpoint.list(sprite)

list_by_name(client, name, opts \\ [])

@spec list_by_name(Sprites.Client.t(), String.t(), keyword()) ::
  {:ok, [t()]} | {:error, term()}

Lists all checkpoints for a sprite by name.

restore(sprite, checkpoint_id)

@spec restore(Sprites.Sprite.t(), String.t()) ::
  {:ok, Enumerable.t()} | {:error, term()}

Restores a sprite from a checkpoint.

Returns a stream of messages. The stream should be consumed to completion.

Examples

{:ok, stream} = Sprites.Checkpoint.restore(sprite, "checkpoint-id")
Enum.each(stream, fn msg -> IO.inspect(msg) end)

restore_by_name(client, name, checkpoint_id)

@spec restore_by_name(Sprites.Client.t(), String.t(), String.t()) ::
  {:ok, Enumerable.t()} | {:error, term()}

Restores a sprite from a checkpoint by name.