Statifier.Actions.InvokeAction (statifier v1.9.0)

View Source

Represents and executes SCXML <invoke> elements for external service communication.

The <invoke> element is used to create an instance of an external service and establish a communication channel with it. This is the standard SCXML mechanism for side effects and external system integration.

Attributes

  • type - The type of external service to invoke (e.g., "elixir", "http")
  • src - The source/location of the service to invoke
  • id - Optional unique identifier for the invocation
  • params - List of parameters to pass to the invoked service
  • source_location - Source code location for error reporting

Supported Invoke Types

  • "elixir" - Invokes Elixir modules and functions directly
  • "http" - Makes HTTP requests to external services (future)
  • "genserver" - Communicates with GenServer processes (future)

Summary

Functions

Dispatches the service invocation using registered handlers.

Evaluates parameter expressions and builds the parameter map for service invocation.

Executes an invoke element within the given state chart context.

Creates a new InvokeAction element.

Types

t()

@type t() :: %Statifier.Actions.InvokeAction{
  id: String.t() | nil,
  params: [Statifier.Actions.Param.t()],
  source_location: map() | nil,
  src: String.t() | nil,
  type: String.t() | nil
}

Functions

dispatch_invoke(invoke, params, state_chart)

@spec dispatch_invoke(t(), map(), Statifier.StateChart.t()) ::
  {:ok, Statifier.StateChart.t()}

Dispatches the service invocation using registered handlers.

This is the secure approach where only registered handlers can be invoked, preventing arbitrary function execution while maintaining SCXML compliance.

evaluate_params(params, state_chart)

@spec evaluate_params([Statifier.Actions.Param.t()], Statifier.StateChart.t()) ::
  {:ok, map(), Statifier.StateChart.t()} | {:error, term()}

Evaluates parameter expressions and builds the parameter map for service invocation.

execute(invoke, state_chart)

@spec execute(t(), Statifier.StateChart.t()) ::
  {:ok, Statifier.StateChart.t()} | {:error, term()}

Executes an invoke element within the given state chart context.

Parameters

  • invoke - The InvokeAction element to execute
  • state_chart - Current StateChart with context and data model

Returns

{:ok, updated_state_chart} or {:error, reason}

new(attrs \\ [])

@spec new(keyword()) :: t()

Creates a new InvokeAction element.

Examples

iex> Statifier.Actions.InvokeAction.new(type: "elixir", src: "NotificationService.send_email")
%Statifier.Actions.InvokeAction{type: "elixir", src: "NotificationService.send_email", params: []}