Skip to main content

Standalone Activities Interactive Demo

SUPPORT, STABILITY, and DEPENDENCY INFO

Temporal SDK support for Standalone Activities is at Pre-release.

All APIs are experimental and may be subject to backwards-incompatible changes.

Standalone Activities let you execute an Activity directly from a Temporal Client — no Workflow required. The Activity is durably enqueued on the Temporal Server, executed by a Worker, and its result is returned to the caller.

Use the interactive demo below to explore the API, experiment with failure scenarios, and see the generated SDK code and CLI command update in real time.

Configure Activity

Failure Simulation

SDK Code

activityOptions := client.StartActivityOptions{
ID: "my-activity-id",
TaskQueue: "my-task-queue",
StartToCloseTimeout: 10 * time.Second,
}

handle, err := c.ExecuteActivity(ctx, activityOptions,
helloworld.Activity, "Hello", "World")
if err != nil {
log.Fatalln("Unable to execute activity", err)
}

var result string
err = handle.Get(ctx, &result)
// result: "Hello, World!"

CLI Command

temporal activity execute \
--type Activity \
--activity-id my-activity-id \
--task-queue my-task-queue \
--start-to-close-timeout 10s \
--input '"World"'

Execution Flow

Client
Your App
Server
Temporal
Task Queue
Worker
Activity
Function

Activity Log

Click "Execute Activity" to run the simulation

How it works

When you call client.ExecuteActivity() (or the equivalent in your SDK), the following happens:

  1. Connect — Your application connects to the Temporal Server.
  2. Schedule — The Server durably persists the Activity execution on the specified Task Queue.
  3. Poll — A Worker polling that Task Queue picks up the Activity Task.
  4. Execute — The Worker runs your Activity function with the provided arguments.
  5. Return — The result is stored by the Server and returned to the original caller via the ActivityHandle.

Because the Server durably persists the Activity, it survives Worker restarts and network interruptions. If the Activity fails, the Server automatically retries it according to the Retry Policy you configure.

Standalone vs Workflow Activities

Workflow ActivityStandalone Activity
Orchestrated byA Workflow DefinitionYour application code
Started withworkflow.ExecuteActivity()client.ExecuteActivity()
Retry policyConfigured per ActivityOptionsConfigured per StartActivityOptions
VisibilityWorkflow Event HistoryActivity Visibility (List/Count)
Use caseComplex, multi-step orchestrationSimple, independent jobs

The Activity function and Worker registration are identical for both — only the execution path differs.


Setup

1. Install the Temporal CLI

Download the Standalone Activity prerelease build of the Temporal CLI:

# macOS (Homebrew)
brew install temporal

# Or download directly from GitHub
# https://github.com/temporalio/cli/releases/tag/v1.6.2-standalone-activity

2. Start a local development server

temporal server start-dev

The server starts at localhost:7233 and the Web UI at http://localhost:8233. Standalone Activities appear under the Activities nav item in the Web UI.

3. Install the SDK

Requires Go SDK v1.41.0 or higher.

go get go.temporal.io/sdk@latest

Clone the samples repository to follow along:

git clone https://github.com/temporalio/samples-go.git
cd samples-go

4. Run the Worker

The Worker registers the Activity and polls the Task Queue. Start it in a dedicated terminal:

go run standalone-activity/helloworld/worker/main.go

5. Execute the Activity

In a separate terminal, run the starter:

go run standalone-activity/helloworld/starter/main.go

Or use the Temporal CLI directly:

temporal activity execute \
--type Activity \
--activity-id my-activity-id \
--task-queue my-task-queue \
--start-to-close-timeout 10s \
--input '"World"'

Key API concepts

ExecuteActivity — start and wait

The primary call. Durably enqueues the Activity, waits for execution, and returns the result:

handle, err := c.ExecuteActivity(ctx, client.StartActivityOptions{
ID: "my-activity-id",
TaskQueue: "my-task-queue",
StartToCloseTimeout: 10 * time.Second,
}, helloworld.Activity, "World")

var result string
err = handle.Get(ctx, &result)

StartActivity — fire and forget

Enqueues the Activity without waiting for it to finish. Useful when you want to kick off long-running work and check back later:

handle, err := c.ExecuteActivity(ctx, options, helloworld.Activity, "World")
// handle.Get() can be called later

List and Count Activities

// List
resp, err := c.ListActivities(ctx, client.ListActivitiesOptions{
Query: "TaskQueue = 'my-task-queue'",
})
for info, err := range resp.Results { ... }

// Count
resp, err := c.CountActivities(ctx, client.CountActivitiesOptions{
Query: "TaskQueue = 'my-task-queue'",
})
log.Println("Total:", resp.Count)

The Query parameter uses the same List Filter syntax as Workflow Visibility.


Next steps

For complete API reference and advanced usage, see the SDK-specific guides: