Spectre.Stack.Installable behaviour (Spectre v0.3.0)

Copy Markdown View Source

Versioned contract implemented by packages that can be installed in a Stack.

manifest/0 and compile/3 run while the Stack definition is compiled and must return immutable data. child_specs/2, when implemented, runs only when a caller explicitly starts Spectre.Stack.Runtime.

Summary

Functions

Defines a static manifest and default data-only compiler.

Returns the supported installable contract version.

Verifies and returns an installable package manifest.

Verifies an installable or raises with a stable contract error.

Callbacks

child_specs(t, keyword)

(optional)
@callback child_specs(
  Spectre.Stack.Installation.t(),
  keyword()
) ::
  [{term(), Supervisor.child_spec()}]
  | {:ok, [{term(), Supervisor.child_spec()}]}
  | {:error, term()}

compile(keyword, arg2, t)

(optional)
@callback compile(keyword(), Macro.t() | nil, Macro.Env.t()) ::
  {:ok, map() | keyword()} | {:error, term()}

manifest()

@callback manifest() :: Spectre.Stack.Package.t() | map() | keyword()

Functions

__using__(manifest_opts)

(macro)

Defines a static manifest and default data-only compiler.

contract_version()

@spec contract_version() :: pos_integer()

Returns the supported installable contract version.

verify(module, contract \\ 1)

@spec verify(module(), pos_integer()) ::
  {:ok, Spectre.Stack.Package.t()} | {:error, term()}

Verifies and returns an installable package manifest.

verify!(module, contract \\ 1)

@spec verify!(module(), pos_integer()) :: Spectre.Stack.Package.t()

Verifies an installable or raises with a stable contract error.