View Source WorkflowMetal.Case.Case (workflow_metal v0.2.1)

GenStateMachine process to present a workflow case.

storage

Storage

The data of :token_table is stored in ETS in the following format:

{token_id, token_schema, token_state, place_id, locked_by_task_id, consumed_by_task_id}

state

State

created+------->active+------->finished
    +              +
    |              |
    |              v
    +---------->terminated

restore

Restore

Restore a case while offering tokens.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Free tokens that locked by the task.

Free tokens that locked by the task.

Offer :free and :locked tokens to the task.

terminate a case.

Link to this section Types

Specs

application() :: WorkflowMetal.Application.t()

Specs

Specs

Specs

options() :: [name: term(), case_schema: case_schema()]

Specs

Specs

t() :: %WorkflowMetal.Case.Case{
  application: application() | nil,
  case_schema: case_schema() | nil,
  end_place: place_schema() | nil,
  free_token_ids: MapSet.t(),
  start_place: place_schema() | nil,
  token_table: :ets.tid() | nil
}

Specs

task_id() :: WorkflowMetal.Storage.Schema.Task.id()

Specs

Specs

Specs

Specs

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

consume_tokens(case_server, task_id)

View Source

Specs

consume_tokens(:gen_statem.server_ref(), task_id()) ::
  {:ok, [token_schema(), ...]} | {:error, :tokens_not_available}

Consume tokens.

Link to this function

fetch_locked_tokens_from_task(case_server, task_id)

View Source

Specs

fetch_locked_tokens_from_task(:gen_statem.server_ref(), task_id()) ::
  {:ok, [token_schema()]}

Free tokens that locked by the task.

eg: free :locked tokens when a task has been abandoned.

Link to this function

free_tokens_from_task(case_server, task_id)

View Source

Specs

free_tokens_from_task(:gen_statem.server_ref(), task_id()) :: :ok

Free tokens that locked by the task.

eg: free :locked tokens when a task has been abandoned.

Link to this function

issue_tokens(case_server, token_schema_list)

View Source

Specs

issue_tokens(:gen_statem.server_ref(), [token_schema(), ...]) ::
  {:ok, [token_schema(), ...]}

Issue tokens.

Link to this function

lock_tokens(case_server, token_ids, task_id)

View Source

Specs

lock_tokens(:gen_statem.server_ref(), [token_id()], task_id()) ::
  {:ok, [token_schema(), ...]} | {:error, :tokens_not_available}

Lock tokens.

Link to this function

offer_tokens_to_task(case_server, task_id)

View Source

Specs

offer_tokens_to_task(:gen_statem.server_ref(), task_id()) ::
  {:ok, [token_schema()]}

Offer :free and :locked tokens to the task.

eg: request :free and :locked tokens when a task restore from storage.

Specs

terminate(:gen_statem.server_ref()) :: :ok

terminate a case.