Spectre.Execution.Handoff (Spectre v0.3.0)

Copy Markdown View Source

Typed Flow/Work exchange carried as portable data.

A handoff names stable Flow or Work IDs and an exact Definition Ref. It cannot contain modules, callbacks or MFAs and does not start anything by itself. The host admits it through the appropriate runtime API.

Summary

Functions

Returns a portable event for a Flow-target handoff.

Restores a handoff and verifies its digest.

Builds a closed typed handoff.

Returns the complete portable handoff representation.

Verifies that a Work-target handoff addresses an exact materialization.

Builds a typed Work-to-Flow handoff event.

Types

endpoint()

@type endpoint() :: %{kind: :flow | :work, ref: String.t()}

t()

@type t() :: %Spectre.Execution.Handoff{
  causation_id: term(),
  correlation_id: term(),
  definition_ref: term(),
  digest: term(),
  id: term(),
  input: term(),
  metadata: term(),
  parent_loop_id: term(),
  provenance: term(),
  schema_version: term(),
  source: term(),
  target: term()
}

Functions

event(handoff)

@spec event(t()) :: {:ok, map()} | {:error, term()}

Returns a portable event for a Flow-target handoff.

flow_to_work(definition_ref, flow_ref, work_ref, input, opts \\ [])

@spec flow_to_work(
  String.t() | Spectre.Definition.Ref.t(),
  term(),
  term(),
  term(),
  keyword()
) ::
  {:ok, t()} | {:error, term()}

Builds a typed Flow-to-Work handoff.

from_data(data)

@spec from_data(map()) :: {:ok, t()} | {:error, term()}

Restores a handoff and verifies its digest.

new(handoff)

@spec new(t() | map() | keyword()) :: {:ok, t()} | {:error, term()}

Builds a closed typed handoff.

to_data(handoff)

@spec to_data(t()) :: map()

Returns the complete portable handoff representation.

validate_target(handoff, materialization)

@spec validate_target(t(), Spectre.Execution.Materialization.t()) ::
  :ok | {:error, term()}

Verifies that a Work-target handoff addresses an exact materialization.

work_to_flow(definition_ref, work_ref, flow_ref, input, opts \\ [])

@spec work_to_flow(
  String.t() | Spectre.Definition.Ref.t(),
  term(),
  term(),
  term(),
  keyword()
) ::
  {:ok, t()} | {:error, term()}

Builds a typed Work-to-Flow handoff event.

work_to_work(definition_ref, source_work, target_work, input, opts \\ [])

@spec work_to_work(
  String.t() | Spectre.Definition.Ref.t(),
  term(),
  term(),
  term(),
  keyword()
) ::
  {:ok, t()} | {:error, term()}

Builds a typed Work-to-Work handoff.