Hephaestus.Runtime.Storage.ETS (hephaestus v0.3.1)

Copy Markdown View Source

ETS-backed storage adapter for workflow instances.

Summary

Functions

Returns a specification to start this module under a supervisor.

Deletes a workflow instance by ID from the default ETS server.

Deletes a workflow instance by ID from the given server.

Retrieves a workflow instance by ID from the default ETS server.

Retrieves a workflow instance by ID from the given server.

Persists a workflow instance in the default ETS server.

Persists a workflow instance in the given server.

Returns all workflow instances matching the given filters from the default ETS server.

Returns all workflow instances matching the given filters from the given server.

Starts the ETS storage process and links it to the caller.

Types

filters()

@type filters() :: keyword()

server()

@type server() :: GenServer.server()

state()

@type state() :: %{table: atom()}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

delete(instance_id)

@spec delete(String.t()) :: :ok

Deletes a workflow instance by ID from the default ETS server.

Removes the entry from the ETS table via :ets.delete/2. The operation is idempotent — deleting a non-existent instance is not an error.

delete(server, instance_id)

@spec delete(server(), String.t()) :: :ok

Deletes a workflow instance by ID from the given server.

get(instance_id)

@spec get(String.t()) :: {:ok, Hephaestus.Core.Instance.t()} | {:error, :not_found}

Retrieves a workflow instance by ID from the default ETS server.

Looks up the instance in the named ETS table via a GenServer.call/2. Returns {:ok, instance} if found, or {:error, :not_found} otherwise.

get(server, instance_id)

@spec get(server(), String.t()) ::
  {:ok, Hephaestus.Core.Instance.t()} | {:error, :not_found}

Retrieves a workflow instance by ID from the given server.

put(instance)

@spec put(Hephaestus.Core.Instance.t()) :: :ok

Persists a workflow instance in the default ETS server.

Inserts or overwrites the instance keyed by its ID using :ets.insert/2.

put(server, instance)

@spec put(server(), Hephaestus.Core.Instance.t()) :: :ok

Persists a workflow instance in the given server.

query(filters)

@spec query(filters()) :: [Hephaestus.Core.Instance.t()]

Returns all workflow instances matching the given filters from the default ETS server.

Performs a full table scan with :ets.tab2list/1 and filters in-memory by :status and :workflow fields. An empty filter list returns all stored instances.

query(server, filters)

@spec query(server(), filters()) :: [Hephaestus.Core.Instance.t()]

Returns all workflow instances matching the given filters from the given server.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Starts the ETS storage process and links it to the caller.

Options