Pipeline.State.VariableEngine (pipeline v0.0.1)

View Source

Manages pipeline variables and state interpolation.

Provides variable assignment, retrieval, and interpolation capabilities for pipeline execution with support for different scoping levels.

Summary

Functions

Clear variables in a specific scope.

Deserialize state from checkpoint data.

Get all variables as a flattened map with scope precedence.

Get a variable value from the state with scope precedence.

Interpolate variables in any data structure recursively.

Interpolate variables in any data structure with execution context access. This allows resolving step results and other execution-time data.

Interpolate variables in any data structure with type preservation for single templates.

Interpolate variables in a string using {{variable_name}} syntax.

Interpolate variables in a string with execution context access. This handles both variable state and step result patterns.

Interpolate variables with type preservation for single templates. This is used for nested pipeline execution where types should be preserved.

Initialize a new variable state.

Serialize state for checkpoint persistence.

Set variables in the specified scope.

Update the current step information in state.

Functions

clear_scope(state, scope)

Clear variables in a specific scope.

deserialize_state(data)

Deserialize state from checkpoint data.

get_all_variables(state)

Get all variables as a flattened map with scope precedence.

get_variable(state, var_name)

Get a variable value from the state with scope precedence.

Lookup order: loop -> session -> global

Parameters

  • state: Current variable state
  • var_name: Variable name to retrieve

Returns

Variable value or nil if not found

interpolate_data(data, state)

Interpolate variables in any data structure recursively.

interpolate_data_with_context(data, state, context)

Interpolate variables in any data structure with execution context access. This allows resolving step results and other execution-time data.

interpolate_data_with_type_preservation(data, state, context)

Interpolate variables in any data structure with type preservation for single templates.

interpolate_string(text, state)

Interpolate variables in a string using {{variable_name}} syntax.

Supports:

  • Simple variables: {{variable_name}}
  • State references: {{state.variable_name}}
  • Nested access: {{state.nested.value}}
  • Arithmetic expressions: {{state.count + 1}}

Examples

iex> state = %{global: %{"name" => "test", "count" => 5}}
iex> Pipeline.State.VariableEngine.interpolate_string("Hello {{name}}, count: {{count}}", state)
"Hello test, count: 5"

interpolate_string_with_context(text, state, context)

Interpolate variables in a string with execution context access. This handles both variable state and step result patterns.

interpolate_with_type_preservation(text, state, context)

Interpolate variables with type preservation for single templates. This is used for nested pipeline execution where types should be preserved.

new_state()

Initialize a new variable state.

serialize_state(state)

Serialize state for checkpoint persistence.

set_variables(state, variables, scope \\ :global)

Set variables in the specified scope.

Parameters

  • state: Current variable state
  • variables: Map of variable names to values
  • scope: Variable scope (:global, :session, :loop)

Examples

iex> state = Pipeline.State.VariableEngine.new_state()
iex> Pipeline.State.VariableEngine.set_variables(state, %{"count" => 1}, :global)
%{global: %{"count" => 1}, session: %{}, loop: %{}, current_step: nil, step_index: 0}

update_step_info(state, step_name, step_index)

Update the current step information in state.