TemporalSdk (temporal_sdk v0.2.11)

View Source

Common Temporal commands and SDK utility functions module.

Summary

Utility functions

evict_workflow(cluster, workflow_execution_or_id)

@spec evict_workflow(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_execution_or_id :: :temporal_sdk.workflow_execution_or_id()
) :: :ok | :temporal_sdk_client.call_result_error()

evict_workflow(cluster, workflow_execution_or_id, opts)

Evicts workflow execution.

format_response(cluster, message_name, response)

@spec format_response(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  message_name :: :temporal_sdk_client.msg_name(),
  response :: {:ok, :temporal_sdk_client.msg()} | {:error, term()}
) :: :temporal_sdk.response()

replay_file(cluster, workflow_mod, filename)

@spec replay_file(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_mod :: module(),
  filename :: :file.name_all()
) ::
  :temporal_sdk.replay_json_ret()
  | {:error, reason :: :file.posix() | :badarg | :terminated | :system_limit}

replay_file(cluster, workflow_mod, filename, opts)

@spec replay_file(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_mod :: module(),
  filename :: :file.name_all(),
  opts :: :temporal_sdk.replay_workflow_opts()
) ::
  :temporal_sdk.replay_json_ret()
  | {:error, reason :: :file.posix() | :badarg | :terminated | :system_limit}

replay_json(cluster, workflow_mod, json)

@spec replay_json(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_mod :: module(),
  json :: :unicode.chardata()
) :: :temporal_sdk.replay_json_ret()

replay_json(cluster, workflow_mod, json, opts)

@spec replay_json(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_mod :: module(),
  json :: :unicode.chardata(),
  opts :: :temporal_sdk.replay_workflow_opts()
) :: :temporal_sdk.replay_json_ret()

replay_task(cluster, task_queue, workflow_type, workflow_mod)

@spec replay_task(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  task_queue :: :unicode.chardata(),
  workflow_type :: atom() | :unicode.chardata(),
  workflow_mod :: module()
) :: :temporal_sdk.replay_json_ret() | :temporal_sdk.call_response_error()

replay_task(cluster, task_queue, workflow_type, workflow_mod, opts)

Workflow commands

await_workflow(cluster, workflow_execution_or_id)

@spec await_workflow(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_execution_or_id :: :temporal_sdk.workflow_execution_or_id()
) ::
  {:ok, :temporal_sdk.workflow_result()}
  | {:error, reason :: map() | :invalid_cluster}
  | :temporal_sdk.call_response_error()

await_workflow(cluster, workflow_execution_or_id, opts)

@spec await_workflow(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_execution_or_id :: :temporal_sdk.workflow_execution_or_id(),
  opts :: :temporal_sdk.await_workflow_opts()
) ::
  {:ok, :temporal_sdk.workflow_result()}
  | {:error, reason :: map() | :invalid_cluster}
  | :temporal_sdk.call_response_error()

cancel_workflow(cluster, workflow_execution_or_id)

@spec cancel_workflow(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_execution_or_id :: :temporal_sdk.workflow_execution_or_id()
) ::
  {:ok,
   :temporal_sdk_proto_service_workflow_binaries."temporal.api.workflowservice.v1.RequestCancelWorkflowExecutionResponse"()}
  | :temporal_sdk.response()

cancel_workflow(cluster, workflow_execution_or_id, opts)

@spec cancel_workflow(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_execution_or_id :: :temporal_sdk.workflow_execution_or_id(),
  opts :: :temporal_sdk.cancel_workflow_opts()
) ::
  {:ok,
   :temporal_sdk_proto_service_workflow_binaries."temporal.api.workflowservice.v1.RequestCancelWorkflowExecutionResponse"()}
  | :temporal_sdk.response()

delete_workflow(cluster, workflow_execution_or_id)

@spec delete_workflow(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_execution_or_id :: :temporal_sdk.workflow_execution_or_id()
) ::
  {:ok,
   :temporal_sdk_proto_service_workflow_binaries."temporal.api.workflowservice.v1.DeleteWorkflowExecutionResponse"()}
  | :temporal_sdk.response()

delete_workflow(cluster, workflow_execution_or_id, opts)

@spec delete_workflow(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_execution_or_id :: :temporal_sdk.workflow_execution_or_id(),
  opts :: :temporal_sdk.delete_workflow_opts()
) ::
  {:ok,
   :temporal_sdk_proto_service_workflow_binaries."temporal.api.workflowservice.v1.DeleteWorkflowExecutionResponse"()}
  | :temporal_sdk.response()

Deletes workflow execution.

SDK Samples Workflow Delete demonstrates command use.

describe_workflow(cluster, workflow_execution_or_id)

@spec describe_workflow(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_execution_or_id :: :temporal_sdk.workflow_execution_or_id()
) ::
  {:ok,
   :temporal_sdk_proto_service_workflow_binaries."temporal.api.workflowservice.v1.DescribeWorkflowExecutionResponse"()}
  | :temporal_sdk.response()

describe_workflow(cluster, workflow_execution_or_id, opts)

@spec describe_workflow(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_execution_or_id :: :temporal_sdk.workflow_execution_or_id(),
  opts :: :temporal_sdk.describe_workflow_opts()
) ::
  {:ok,
   :temporal_sdk_proto_service_workflow_binaries."temporal.api.workflowservice.v1.DescribeWorkflowExecutionResponse"()}
  | :temporal_sdk.response()

get_workflow_history(cluster, workflow_execution_or_id)

@spec get_workflow_history(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_execution_or_id :: :temporal_sdk.workflow_execution_or_id()
) ::
  {:ok,
   [
     :temporal_sdk_proto_service_workflow_binaries."temporal.api.history.v1.HistoryEvent"(),
     ...
   ]}
  | :temporal_sdk.call_response_error()
  | {:error, reason :: term()}

get_workflow_history(cluster, workflow_execution_or_id, opts)

@spec get_workflow_history(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_execution_or_id :: :temporal_sdk.workflow_execution_or_id(),
  opts :: :temporal_sdk.get_workflow_history_opts()
) ::
  {:ok,
   :temporal_sdk_proto_service_workflow_binaries."temporal.api.workflowservice.v1.GetWorkflowExecutionHistoryResponse"()}
  | {:ok,
     [
       :temporal_sdk_proto_service_workflow_binaries."temporal.api.history.v1.HistoryEvent"(),
       ...
     ]}
  | {:ok,
     [
       :temporal_sdk_proto_service_workflow_binaries."temporal.api.history.v1.HistoryEvent"(),
       ...
     ], json :: iodata(), :file.name_all()}
  | {:ok,
     [
       :temporal_sdk_proto_service_workflow_binaries."temporal.api.history.v1.HistoryEvent"(),
       ...
     ], json :: iodata()}
  | :temporal_sdk.call_response_error()
  | {:error,
     reason ::
       :file.posix()
       | :badarg
       | :terminated
       | :system_limit
       | :timeout
       | map()
       | term()}

get_workflow_state(cluster, workflow_execution_or_id)

@spec get_workflow_state(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_execution_or_id :: :temporal_sdk.workflow_execution_or_id()
) :: :temporal_sdk.get_workflow_state_ret()

get_workflow_state(cluster, workflow_execution_or_id, opts)

query_workflow(cluster, workflow_execution_or_id, query_type)

@spec query_workflow(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_execution_or_id :: :temporal_sdk.workflow_execution_or_id(),
  query_type :: :unicode.chardata()
) ::
  {:ok,
   :temporal_sdk_proto_service_workflow_binaries."temporal.api.workflowservice.v1.QueryWorkflowResponse"()}
  | :temporal_sdk.response()

query_workflow(cluster, workflow_execution_or_id, query_type, opts)

@spec query_workflow(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_execution_or_id :: :temporal_sdk.workflow_execution_or_id(),
  query_type :: :unicode.chardata(),
  opts :: :temporal_sdk.query_workflow_opts()
) ::
  {:ok,
   :temporal_sdk_proto_service_workflow_binaries."temporal.api.workflowservice.v1.QueryWorkflowResponse"()}
  | :temporal_sdk.response()

reset_workflow(cluster, workflow_execution_or_id)

@spec reset_workflow(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_execution_or_id :: :temporal_sdk.workflow_execution_or_id()
) ::
  {:ok,
   :temporal_sdk_proto_service_workflow_binaries."temporal.api.workflowservice.v1.ResetWorkflowExecutionResponse"()}
  | :temporal_sdk.response()

reset_workflow(cluster, workflow_execution_or_id, opts)

@spec reset_workflow(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_execution_or_id :: :temporal_sdk.workflow_execution_or_id(),
  opts :: :temporal_sdk.reset_workflow_opts()
) ::
  {:ok,
   :temporal_sdk_proto_service_workflow_binaries."temporal.api.workflowservice.v1.ResetWorkflowExecutionResponse"()}
  | :temporal_sdk.response()

signal_workflow(cluster, workflow_execution_or_id, signal_name)

@spec signal_workflow(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_execution_or_id :: :temporal_sdk.workflow_execution_or_id(),
  signal_name :: :unicode.chardata()
) ::
  {:ok,
   :temporal_sdk_proto_service_workflow_binaries."temporal.api.workflowservice.v1.SignalWorkflowExecutionResponse"()}
  | :temporal_sdk.response()

signal_workflow(cluster, workflow_execution_or_id, signal_name, opts)

@spec signal_workflow(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_execution_or_id :: :temporal_sdk.workflow_execution_or_id(),
  signal_name :: :unicode.chardata(),
  opts :: :temporal_sdk.signal_workflow_opts()
) ::
  {:ok,
   :temporal_sdk_proto_service_workflow_binaries."temporal.api.workflowservice.v1.SignalWorkflowExecutionResponse"()}
  | :temporal_sdk.response()

start_workflow(cluster, task_queue, workflow_type)

@spec start_workflow(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  task_queue :: :unicode.chardata(),
  workflow_type :: atom() | :unicode.chardata()
) ::
  {:ok, :temporal_sdk.start_workflow_ret()}
  | {:error, reason :: map() | :invalid_cluster}
  | :temporal_sdk.call_response_error()

start_workflow(cluster, task_queue, workflow_type, opts)

terminate_workflow(cluster, workflow_execution_or_id)

@spec terminate_workflow(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_execution_or_id :: :temporal_sdk.workflow_execution_or_id()
) ::
  {:ok,
   :temporal_sdk_proto_service_workflow_binaries."temporal.api.workflowservice.v1.TerminateWorkflowExecutionResponse"()}
  | :temporal_sdk.response()

terminate_workflow(cluster, workflow_execution_or_id, opts)

@spec terminate_workflow(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_execution_or_id :: :temporal_sdk.workflow_execution_or_id(),
  opts :: :temporal_sdk.terminate_workflow_opts()
) ::
  {:ok,
   :temporal_sdk_proto_service_workflow_binaries."temporal.api.workflowservice.v1.TerminateWorkflowExecutionResponse"()}
  | :temporal_sdk.response()

Terminates workflow execution.

In most cases, it is recommended to use the cancel_workflow/3 command instead.

SDK Samples Workflow Terminate demonstrates command use.

wait_workflow(cluster, workflow_execution_or_id)

@spec wait_workflow(
  cluster :: :temporal_sdk_cluster.cluster_name(),
  workflow_execution_or_id :: :temporal_sdk.workflow_execution_or_id()
) :: :temporal_sdk.workflow_result() | no_return()

wait_workflow(cluster, workflow_execution_or_id, opts)