Temporalex.Client (Temporalex v0.2.0)

Copy Markdown View Source

Client for interacting with Temporal workflows from outside workflow code.

Used to start, signal, query, and cancel workflows programmatically.

Usage

# Get client from a running worker
{:ok, client} = Temporalex.Client.connect("http://localhost:7233")

# Start a workflow
{:ok, run_id} = Temporalex.Client.start_workflow(client, "default",
  workflow_id: "order-123",
  workflow_type: "MyApp.Workflows.Order",
  task_queue: "my-queue",
  input: %{order_id: "123"}
)

# Signal a workflow
:ok = Temporalex.Client.signal_workflow(client, "default",
  workflow_id: "order-123",
  signal_name: "approve",
  input: %{approved: true}
)

# Query a workflow
{:ok, result} = Temporalex.Client.query_workflow(client, "default",
  workflow_id: "order-123",
  query_type: "status"
)

Summary

Functions

Cancel a running workflow.

Connect to a Temporal server. Returns {:ok, client} or {:error, reason}.

Query a workflow's state.

Send a signal to a running workflow.

Start a workflow execution.

Functions

cancel_workflow(client, namespace, opts)

Cancel a running workflow.

Options (required)

  • :workflow_id — target workflow ID

Options (optional)

  • :run_id — specific run ID
  • :reason — cancellation reason

connect(url, opts \\ [])

Connect to a Temporal server. Returns {:ok, client} or {:error, reason}.

query_workflow(client, namespace, opts)

Query a workflow's state.

Options (required)

  • :workflow_id — target workflow ID
  • :query_type — query name

Options (optional)

  • :args — query arguments
  • :run_id — specific run ID

signal_workflow(client, namespace, opts)

Send a signal to a running workflow.

Options (required)

  • :workflow_id — target workflow ID
  • :signal_name — signal name

Options (optional)

  • :input — signal payload
  • :run_id — specific run ID (empty string for latest)

start_workflow(client, namespace, opts)

Start a workflow execution.

Options (required)

  • :workflow_id — unique workflow identifier
  • :workflow_type — workflow type name (e.g., "MyApp.Workflows.Order")
  • :task_queue — task queue name

Options (optional)

  • :input — workflow input (will be ETF-encoded)
  • :request_id — idempotency key (auto-generated if omitted)
  • :execution_timeout_ms — total time the workflow is allowed to run (across continue-as-new chains)
  • :run_timeout_ms — time a single run is allowed to take
  • :task_timeout_ms — time a single workflow task is allowed to take before being retried by the server