View Source WorkflowMetal.Task.Task (workflow_metal v0.2.1)
A GenStateMachine
to lock tokens and generate workitem
.
storage
Storage
The data of :token_table
is stored in ETS in the following format:
{token_id, token_schema, token_state}
The data of :workitem_table
is stored in ETS in the following format:
{workitem_id, workitem_state}
state
State
started+-------->allocated+------->executing+------->completed
+ + +
| | |
| v |
+----------->abandoned<------------+
restore
Restore
Restore a task while restoring its non-ending(created
and started
) workitems.
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Discard tokens when the case withdraw them.
Abandon the task forcibly.
Pre-execute the given task, return with locked tokens.
Receive tokens from the case.
Update the state of a workitem in the workitem_table.
Link to this section Types
Specs
application() :: WorkflowMetal.Application.t()
Specs
case_id() :: WorkflowMetal.Storage.Schema.Case.id()
Specs
on_preexecute() :: {:ok, [token_schema(), ...]} | {:error, :tokens_not_available} | {:error, :task_not_enabled}
Specs
options() :: [name: term(), task_schema: task_schema()]
Specs
place_id() :: WorkflowMetal.Storage.Schema.Place.id()
Specs
t() :: %WorkflowMetal.Task.Task{ application: application() | nil, task_schema: task_schema() | nil, token_table: :ets.tid() | nil, transition_schema: transition_schema() | nil, workitem_table: :ets.tid() | nil }
Specs
task_id() :: WorkflowMetal.Storage.Schema.Task.id()
Specs
task_schema() :: WorkflowMetal.Storage.Schema.Task.t()
Specs
token_id() :: WorkflowMetal.Storage.Schema.Token.id()
Specs
token_schema() :: WorkflowMetal.Storage.Schema.Token.t()
Specs
transition_id() :: WorkflowMetal.Storage.Schema.Transition.id()
Specs
transition_schema() :: WorkflowMetal.Storage.Schema.Transition.t()
Specs
workflow_id() :: WorkflowMetal.Storage.Schema.Workflow.id()
Specs
workflow_identifier() :: WorkflowMetal.Workflow.Supervisor.workflow_identifier()
Specs
workitem_id() :: WorkflowMetal.Storage.Schema.Workitem.id()
Specs
workitem_schema() :: WorkflowMetal.Storage.Schema.Workitem.t()
Specs
workitem_state() :: WorkflowMetal.Storage.Schema.Workitem.state()
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Specs
discard_tokens(:gen_statem.server_ref(), [token_schema()]) :: :ok
Discard tokens when the case withdraw them.
eg: these tokens has been locked by the other token.
Specs
force_abandon(:gen_statem.server_ref()) :: :ok
Abandon the task forcibly.
Specs
preexecute(:gen_statem.server_ref()) :: on_preexecute()
Pre-execute the given task, return with locked tokens.
lock-tokens
Lock tokens
If tokens are already locked by the task, return :ok
too.
When the task is not enabled, return {:error, :task_not_enabled}
.
When fail to lock tokens, return {:error, :tokens_not_available}
.
Specs
receive_tokens(:gen_statem.server_ref(), [token_schema()]) :: :ok
Receive tokens from the case.
Specs
update_workitem(:gen_statem.server_ref(), workitem_id(), workitem_state()) :: :ok
Update the state of a workitem in the workitem_table.