WorkflowDelete (temporal_sdk_samples v0.2.0)

View Source

Delete workflow execution command sample.

This sample demonstrates the use of the TemporalSdk.delete_workflow/3 Temporal command. Example is using TemporalSdk.get_workflow_state/2 function to get workflow execution state before and after deletion. Calling TemporalSdk.get_workflow_state/2 after workflow execution is deleted returns a gRPC error: "workflow execution not found ...".

Additionally, sample attaches the telemetry event logger defined in the :workflow_eviction module. When the deletion command is executed, SDK evicts workflow execution, and the workflow executor's :closing_state is set to {:external_evict, :deleted}.

Example run:

Elixir

iex(1)> WorkflowDelete.run()
WF execution state before deletion:
  {:ok, :running}

[temporal_sdk,workflow,executor,stop]: 3 -> {external_evict,deleted}

WF execution state after deletion:
  {:error, "workflow execution not found for workflow ID \"Elixir.WorkflowTerminate.Workflow/4e528d5e-ca9d-4882-b93a-9d163477209d\" and run ID \"019e16d0-8ce7-776d-bbd4-53f59bb8c754\""}

:ok

Sample source: lib/workflow_delete

Erlang

1> workflow_delete:run().
WF execution state before deletion:
  {ok,running}

[temporal_sdk,workflow,executor,stop]: 3 -> {external_evict,deleted}

WF execution state after deletion:
  {error,<<"workflow execution not found for workflow ID \"workflow_terminate_workflow/7bb27ec8-55fe-44bf-99a1-664991635de7\" and run ID \"019e16d2-e814-711b-8bea-2e694966acf5\"">>}

ok

Sample source: src/workflow_delete

Summary

Functions

run()

@spec run() :: :ok | no_return()