CMDCOrchestrator.RunStore behaviour (cmdc_orchestrator v0.5.0)

Copy Markdown View Source

Workflow run 账本后端 behaviour 与默认包装函数。

cmdc_orchestrator 只定义通用接口和 ETS 开发后端;企业 Phoenix 平台可以 自行实现 Ecto/Oban/审计集成后端。

Summary

Types

backend()

@type backend() :: module()

Callbacks

append_event(t, arg2)

@callback append_event(
  String.t(),
  CMDCOrchestrator.RunEvent.t() | {String.t() | atom(), map()} | map()
) ::
  {:ok, CMDCOrchestrator.RunEvent.t()} | {:error, term()}

delete_run(t)

@callback delete_run(String.t()) :: :ok | {:error, term()}

list_events(t, keyword)

@callback list_events(
  String.t(),
  keyword()
) :: {:ok, [CMDCOrchestrator.RunEvent.t()]} | {:error, term()}

list_node_runs(t)

@callback list_node_runs(String.t()) ::
  {:ok, [CMDCOrchestrator.NodeRun.t()]} | {:error, term()}

list_runs(keyword)

@callback list_runs(keyword()) :: {:ok, [CMDCOrchestrator.Run.t()]} | {:error, term()}

load_run(t)

@callback load_run(String.t()) :: {:ok, CMDCOrchestrator.Run.t()} | {:error, term()}

save_run(t)

@callback save_run(CMDCOrchestrator.Run.t()) ::
  {:ok, CMDCOrchestrator.Run.t()} | {:error, term()}

update_node_run(t, t, arg3)

@callback update_node_run(
  String.t(),
  String.t(),
  map() | (CMDCOrchestrator.NodeRun.t() -> CMDCOrchestrator.NodeRun.t())
) :: {:ok, CMDCOrchestrator.NodeRun.t()} | {:error, term()}

update_run(t, arg2)

@callback update_run(
  String.t(),
  map() | (CMDCOrchestrator.Run.t() -> CMDCOrchestrator.Run.t())
) ::
  {:ok, CMDCOrchestrator.Run.t()} | {:error, term()}

upsert_node_run(t)

@callback upsert_node_run(CMDCOrchestrator.NodeRun.t()) ::
  {:ok, CMDCOrchestrator.NodeRun.t()} | {:error, term()}

Functions

append_event(store, run_id, event)

@spec append_event(
  backend(),
  String.t(),
  CMDCOrchestrator.RunEvent.t() | {String.t() | atom(), map()} | map()
) :: {:ok, CMDCOrchestrator.RunEvent.t()} | {:error, term()}

backend(opts \\ [])

@spec backend(keyword()) :: backend()

解析 RunStore 后端。

delete_run(store, run_id)

@spec delete_run(backend(), String.t()) :: :ok | {:error, term()}

list_events(store, run_id, opts \\ [])

@spec list_events(backend(), String.t(), keyword()) ::
  {:ok, [CMDCOrchestrator.RunEvent.t()]} | {:error, term()}

list_node_runs(store, run_id)

@spec list_node_runs(backend(), String.t()) ::
  {:ok, [CMDCOrchestrator.NodeRun.t()]} | {:error, term()}

list_runs(store, opts \\ [])

@spec list_runs(
  backend(),
  keyword()
) :: {:ok, [CMDCOrchestrator.Run.t()]} | {:error, term()}

load_run(store, run_id)

@spec load_run(backend(), String.t()) ::
  {:ok, CMDCOrchestrator.Run.t()} | {:error, term()}

save_run(store, run)

@spec save_run(backend(), CMDCOrchestrator.Run.t()) ::
  {:ok, CMDCOrchestrator.Run.t()} | {:error, term()}

update_node_run(store, run_id, node_id, attrs_or_fun)

@spec update_node_run(
  backend(),
  String.t(),
  String.t(),
  map() | (CMDCOrchestrator.NodeRun.t() -> CMDCOrchestrator.NodeRun.t())
) :: {:ok, CMDCOrchestrator.NodeRun.t()} | {:error, term()}

update_run(store, run_id, attrs_or_fun)

@spec update_run(
  backend(),
  String.t(),
  map() | (CMDCOrchestrator.Run.t() -> CMDCOrchestrator.Run.t())
) ::
  {:ok, CMDCOrchestrator.Run.t()} | {:error, term()}

upsert_node_run(store, node_run)

@spec upsert_node_run(backend(), CMDCOrchestrator.NodeRun.t()) ::
  {:ok, CMDCOrchestrator.NodeRun.t()} | {:error, term()}