Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions standalone-activity/helloworld/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
This sample demonstrates how to use a Standalone Activity (executing an Activity without wrapping it in a Workflow)
This sample demonstrates how to use a Standalone Activity (executing an Activity without wrapping it in a Workflow).
It also shows you how to use the `ListActivities` and `CountActivities` APIs.

## NOTE: This new feature is not ready for use yet. It will only work once we release a special CLI server for pre-release, once that happens, this README will be updated.

### Steps to run this sample (with expected output):
1) Run a [Temporal server](https://github.com/temporalio/samples-go/tree/main/#how-to-use). (If you are going to run locally, you will want to start it in another terminal; this command is blocking and runs until it receives a SIGINT (Ctrl + C) command.)
Expand Down Expand Up @@ -27,7 +30,6 @@ You should see two console log lines:
For example:
```bash
2025/12/22 15:00:15 INFO No logger configured for temporal client. Created default one.

2025/12/22 15:00:16 INFO Started Worker Namespace default TaskQueue standalone-activity-helloworld WorkerID 82087
```

Expand All @@ -39,13 +41,17 @@ For example:
go run standalone-activity/helloworld/starter/main.go
```

You should see two console log lines: 1) Creating the logger, 2) The standalone activity result
You should see something similar to the following output.

For example:
```bash
2026/02/05 11:30:47 INFO No logger configured for temporal client. Created default one.

2026/02/05 11:30:47 Started standalone activity ActivityID standalone_activity_helloworld_ActivityID RunID 019c2f49-1ff1-7a44-beee-7ff4b36ecc27

2026/02/05 11:30:47 Activity result: Hello Temporal!
2026/02/23 14:12:00 INFO No logger configured for temporal client. Created default one.
2026/02/23 14:12:00 Started standalone activity ActivityID standalone_activity_helloworld_ActivityID RunID 019c8c8f-324f-7c06-a92e-a9f7e612ce69
2026/02/23 14:12:00 Activity result: Hello Temporal!
2026/02/23 14:12:00 ListActivity results
2026/02/23 14:12:00 ActivityID: standalone_activity_helloworld_ActivityID, Type: Activity, Status: Completed
2026/02/23 14:12:00 CountActivities: 1
```

If you run the starter code multiple times, you should see additional `ListActivity` results, as more activites are run.
The same goes for the number of activities from `CountActivities`.
27 changes: 26 additions & 1 deletion standalone-activity/helloworld/starter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func main() {
// Normally we would execute a workflow, but in this case we are executing an activity directly.
handle, err := c.ExecuteActivity(context.Background(), activityOptions, helloworld.Activity, "Temporal")
if err != nil {
log.Fatalln("Unable to execute workflow", err)
log.Fatalln("Unable to execute activity", err)
}

log.Println("Started standalone activity", "ActivityID", handle.GetID(), "RunID", handle.GetRunID())
Expand All @@ -43,4 +43,29 @@ func main() {
log.Fatalln("Unable get standalone activity result", err)
}
log.Println("Activity result:", result)

resp, err := c.ListActivities(context.Background(), client.ListActivitiesOptions{
Query: "TaskQueue = 'standalone-activity-helloworld'",
})
if err != nil {
log.Fatalln("Unable to list activities", err)
}

log.Println("ListActivity results")
for info, err := range resp.Results {
if err != nil {
log.Fatalln("Error iterating activities", err)
}
log.Printf("\tActivityID: %s, Type: %s, Status: %v\n",
info.ActivityID, info.ActivityType, info.Status)
}

resp1, err := c.CountActivities(context.Background(), client.CountActivitiesOptions{
Query: "TaskQueue = 'standalone-activity-helloworld'",
})
if err != nil {
log.Fatalln("Unable to count activities", err)
}

log.Println("Total activities:", resp1.Count)
}