Spectre.Action.Provider behaviour (Spectre v0.3.0)

Copy Markdown View Source

Contract and safe invocation facade for action providers.

Providers own discovery and execution. Spectre owns provider registration, policy, persistence, idempotency, and the effect lifecycle.

Summary

Functions

Returns normalized discovery specs for a mounted provider.

Executes one action through its already-resolved provider mount.

Types

provider_result()

@type provider_result() :: {:ok, term()} | {:error, term()}

Callbacks

actions(keyword)

(optional)
@callback actions(keyword()) ::
  [Spectre.Action.Spec.t() | map()]
  | {:ok, [Spectre.Action.Spec.t() | map()]}
  | {:error, term()}

execute(t, t, keyword)

@callback execute(Spectre.Action.t(), Spectre.Context.t(), keyword()) :: term()

schema_hash(t, keyword)

(optional)
@callback schema_hash(
  Spectre.Action.t(),
  keyword()
) :: String.t() | nil | {:ok, String.t() | nil}

Functions

actions(mount, visibility \\ :planner)

@spec actions(Spectre.Action.Provider.Mount.t(), :planner | :all) ::
  {:ok, [Spectre.Action.Spec.t()]} | {:error, term()}

Returns normalized discovery specs for a mounted provider.

execute(mount, action, ctx)

Executes one action through its already-resolved provider mount.

If a planner attached a schema hash, the provider must support schema verification and report the same hash before execution.