View Source wfnet_tasks (wfnet v0.1.0)

Functions for handling the workflow task states and results.

All the data is kept in an ETS table, which is created with wfnet_net:load_ets/1.

Each record in the table is of type wfnet:task_rec(), see include/wfnet.hrl for details.

{ Id, Type, State, Pred, Succ, Data, Result }

Summary

Functions

collect and return the results of all the tasks.
collect and return the states of all the tasks.

Return the result field of a task

Return the state field of a task

save a task's result
save a task's state

Types

-type task_id() :: integer().
-type task_state() :: inactive | done | waiting | running.

Functions

-spec all_results(ets:table()) -> {ok, map()} | {error, term()}.
collect and return the results of all the tasks.
-spec all_states(ets:table()) -> {ok, map()} | {error, term()}.
collect and return the states of all the tasks.
-spec get_result(ets:table(), task_id()) -> {ok, term()} | {error, term()}.

Return the result field of a task

In case of non-existent table or task record error will be returned.

The result field will be returned, whether the task has run or not.
-spec get_state(ets:table(), task_id()) -> {ok, task_state()} | {error, term()}.

Return the state field of a task

In case of non-existent table or task record error will be returned.
Link to this function

put_result(Tab_id, Id, Result)

View Source
-spec put_result(ets:table(), task_id(), term()) -> ok | {error, term()}.
save a task's result
Link to this function

put_state(Tab_id, Id, Task_state)

View Source
-spec put_state(ets:table(), task_id(), task_state()) -> ok | {error, term()}.
save a task's state