Journey.Execution (Journey v0.0.5) View Source
An execution of a process.
An execution gets created when you call
execution = Journey.Process.execute(process)
The execution can then be updated with new values
{:ok, updated_execution} = Journey.Execution.update_value(
execution.execution_id,
:first_name,
"Luigi")
and its can be introspected.
> updated_execution |> Journey.Execution.read_value(:first_name)
{:computed, "Luigi"}
Link to this section Summary
Functions
Get all steps in the execution, and their current state.
Get all the steps in the execution that are blocked by other steps.
Returns a human friendly string containing the summary of the current status of the execution.
Get all the steps in an execution that have yet to receive a value.
Fetches the value contained in a specificified step.
Load an execution from store, given its execution id.
Load an execution from store, given its execution id.
Read value from an execution.
Update a value in an execution, given the execution or execution id. The new value gets immediately persisted. Any steps that become unblocked by this value will start computing.
Link to this section Types
Specs
t() :: %Journey.Execution{ execution_id: String.t(), process: Journey.Process, save_version: integer(), values: map() }
Stores the information related to an execution of a process.
execution_id
The id of this execution.
process
The process that this execution is running.
values
The values associated with this execution, in various states of computation.
save_version
The version of this execution. Every time an execution gets updated, it is persisted, and its save_version value gets incremented.
Link to this section Functions
Specs
get_all_values(t()) :: [ {:not_computed | :computed | :computing | :failed, [status: any(), value: any(), self_computing: boolean(), blocked_by: list()]} ]
Get all steps in the execution, and their current state.
iex(9)> execution_id |> Journey.Execution.get_all_values
[
started_at: [
status: :computed,
value: 1615790505,
self_computing: false,
blocked_by: []
],
first_name: [
status: :not_computed,
value: nil,
self_computing: false,
blocked_by: []
],
birth_month: [
status: :not_computed,
value: nil,
self_computing: false,
blocked_by: []
],
birth_day: [
status: :not_computed,
value: nil,
self_computing: false,
blocked_by: []
],
astrological_sign: [
status: :not_computed,
value: nil,
self_computing: true,
blocked_by: [:birth_month, :birth_day]
],
horoscope: [
status: :not_computed,
value: nil,
self_computing: true,
blocked_by: [:first_name, :astrological_sign]
]
]
Specs
Get all the steps in the execution that are blocked by other steps.
> execution |> Journey.Execution.get_blocked_steps()
[
astrological_sign: %Journey.Value{
name: :astrological_sign,
status: :not_computed,
update_time: 0,
value: nil
},
horoscope: %Journey.Value{
name: :horoscope,
status: :not_computed,
update_time: 0,
value: nil
}
]
Specs
Returns a human friendly string containing the summary of the current status of the execution.
> execution |> Journey.Execution.get_summary |> IO.puts
Execution Summary
Execution ID: keo56rvimq
Execution started: 2021-03-15 06:41:45Z
Revision: 1
All Steps:
[started_at]: '1615790505'. Blocked by: []. Self-computing: false
[first_name]: 'not_computed'. Blocked by: []. Self-computing: false
[birth_month]: 'not_computed'. Blocked by: []. Self-computing: false
[birth_day]: 'not_computed'. Blocked by: []. Self-computing: false
[astrological_sign]: 'not_computed'. Blocked by: [birth_month, birth_day]. Self-computing: true
[horoscope]: 'not_computed'. Blocked by: [first_name, astrological_sign]. Self-computing: true
:ok
Specs
Get all the steps in an execution that have yet to receive a value.
> Journey.Execution.get_unfilled_steps(execution)
[
astrological_sign: %Journey.Value{
name: :astrological_sign,
status: :not_computed,
update_time: 0,
value: nil
},
birth_day: %Journey.Value{
name: :birth_day,
status: :not_computed,
update_time: 0,
value: nil
},
birth_month: %Journey.Value{
name: :birth_month,
status: :not_computed,
update_time: 0,
value: nil
},
first_name: %Journey.Value{
name: :first_name,
status: :not_computed,
update_time: 0,
value: nil
},
horoscope: %Journey.Value{
name: :horoscope,
status: :not_computed,
update_time: 0,
value: nil
}
]
Fetches the value contained in a specificified step.
iex(1)> Journey.Execution.get_value(execution_id, :birth_day)
26
Specs
Load an execution from store, given its execution id.
{:ok, execution} = Journey.Execution.load(execution_id)
Specs
Load an execution from store, given its execution id.
execution = Journey.Execution.load!(execution_id)
Specs
read_value(t(), atom()) :: {:not_computed | :computing | :computed | :failed | :error, atom() | nil | Journey.Execution}
Read value from an execution.
> execution |> Journey.Execution.read_value(:first_name)
{:computed, "Mario"}
> execution |> Journey.Execution.read_value(:astrological_sign)
{:computing, nil}
> execution |> Journey.Execution.read_value(:horoscope_name)
{:not_computed, nil}
> execution |> Journey.Execution.read_value(:ssn)
{:error, :unknown_step}
Specs
update_value(String.t(), atom(), any()) :: {:ok, t()}
update_value(t(), atom(), any()) :: {:ok, t()}
Update a value in an execution, given the execution or execution id. The new value gets immediately persisted. Any steps that become unblocked by this value will start computing.
The function returns a tuple that, in case of success, includes the updated execution.
{:ok, updated_execution} = Journey.Execution.update_value(execution_id, :first_name, "Luigi")
{:unknown_step, _} = Journey.Execution.update_value(execution_id, :ssn, "111-11-11")
{:unknown_execution_id, _} = Journey.Execution.update_value(no_such_execution, :first_name, "Luigi")