Sprites.Checkpoint (Sprites v0.2.0)
View SourceCheckpoint 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
@type t() :: %Sprites.Checkpoint{ comment: String.t() | nil, create_time: DateTime.t() | nil, history: [String.t()], id: String.t() }
Functions
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
@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)
@spec create_by_name(Sprites.Client.t(), String.t(), keyword()) :: {:ok, Enumerable.t()} | {:error, term()}
Creates a new checkpoint for a sprite by name.
Creates a checkpoint from a map.
@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")
@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.
@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)
@spec list_by_name(Sprites.Client.t(), String.t(), keyword()) :: {:ok, [t()]} | {:error, term()}
Lists all checkpoints for a sprite by name.
@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)
@spec restore_by_name(Sprites.Client.t(), String.t(), String.t()) :: {:ok, Enumerable.t()} | {:error, term()}
Restores a sprite from a checkpoint by name.