Temporalex.Workflow.API (Temporalex v0.3.1)

Copy Markdown View Source

Workflow primitives available from executor-owned workflow processes.

Summary

Functions

cancelled?()

context!()

context_key()

deprecate_patch(patch_id)

execute_activity(type, input, opts \\ [])

execute_child_workflow(workflow, input, opts \\ [])

Start a child workflow and block until it completes.

workflow may be a module that uses Temporalex.Workflow (its __workflow_type__/0 is consulted) or a workflow type string.

Options:

  • :workflow_id (required) — child workflow identifier
  • :task_queue — defaults to the parent's task queue
  • :execution_timeout_ms, :run_timeout_ms, :task_timeout_ms
  • :retry_policy — keyword list, same shape as activity retry policies
  • :parent_close_policy:terminate (default), :abandon, :request_cancel
  • :workflow_id_reuse_policy:allow_duplicate (default), :allow_duplicate_failed_only, :reject_duplicate, :terminate_if_running

Returns {:ok, result} on completion, {:error, %Temporalex.ChildWorkflowFailure{...}} on child failure or start failure, {:cancelled, ...} on cancellation.

execute_local_activity(type, input, opts \\ [])

Schedule a local activity — runs in-process on this worker rather than via the Temporal task queue, with durability provided by a history marker.

Faster than regular activities for short, deterministic work that doesn't need cross-worker scheduling. The activity body still runs in the activity task supervisor; Temporal Core records a marker so replay is correct.

install_context(context)

now()

parallel(funs)

patched?(patch_id)

phase(initial_state, opts)

publish_state(state)

random()

signal_child_workflow(workflow_id, signal_name, args \\ [], opts \\ [])

Send a signal to a child workflow that was started by this workflow.

workflow_id must match the workflow_id you used in execute_child_workflow/3. The signal is sent durably — the call blocks until Temporal confirms delivery (or fails).

Returns :ok on successful delivery, {:error, %Temporalex.ApplicationError{}} if the target workflow doesn't exist or the signal can't be delivered.

This is a "fire and confirm delivery" primitive: the signal handler in the child runs asynchronously to the parent; success only means Temporal has accepted the signal for delivery.

sleep(duration_ms)

update_state(fun)

upsert_search_attributes(attrs)

uuid4()

wait_for_signal(name)

workflow_info()