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

A GenStateMachine to run a workitem.

flow

Flow

The workitem starts to execute, when the workitem is created.

If the executor returns :started, you can call :complete with the workitem_output to complete the workitem manually(asynchronously).

If the executor returns {:completed, workitem_output}, the workitem is completed immediately.

The task can abandon the workitem when needed.

state

State

created+-------->started+------->completed
    +               +
    |               |
    |               v
    +---------->abandoned

restore

Restore

Restore itself only.

Link to this section Summary

Functions

Abandon a workitem.

Returns a specification to start this module under a supervisor.

Complete a workitem.

Link to this section Types

Specs

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

Specs

Specs

on_abandon() :: :ok

Specs

on_complete() :: :ok | {:error, :workitem_not_available}

Specs

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

Specs

t() :: %WorkflowMetal.Workitem.Workitem{
  application: application() | nil,
  workitem_schema: workitem_schema() | nil
}

Specs

Specs

Specs

Specs

workitem_id() :: WorkflowMetal.Storage.Schema.Workitem.id()

Specs

workitem_output() :: WorkflowMetal.Storage.Schema.Workitem.output()

Specs

workitem_schema() :: WorkflowMetal.Storage.Schema.Workitem.t()

Link to this section Functions

Link to this function

abandon(workitem_server)

View Source

Specs

abandon(:gen_statem.server_ref()) :: :ok

Abandon a workitem.

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

complete(workitem_server, output)

View Source

Specs

Complete a workitem.