new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Temporal · all subjects

activities: basics and execution

9 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Standalone Activities definition and execution

Standalone Activities are Activities that run independently without being orchestrated by a Workflow. Instead of starting an Activity from within a Workflow Definition, you start a Standalone Activity directly from a Temporal Client. The way you write the Activity and register it with a Worker is identical to Workflow Activities. The same Activity can be executed both as a Standalone Activity and as a Workflow Activity.

.NET Activity attribute and syntax

An Activity in the Temporal .NET SDK is a method decorated with the [Activity] attribute. The Activity method can be async and return Task<T>. Example: [Activity] public static Task<string> ComposeGreetingAsync(ComposeGreetingInput input) => Task.FromResult($"{input.Greeting}, {input.Name}!");

ExecuteActivityAsync for Standalone Activities in .NET

Use client.ExecuteActivityAsync() to execute a Standalone Activity and wait for the result. Call this from application code, not from inside a Workflow Definition. This durably enqueues the Standalone Activity in the Temporal Server, waits for it to be executed on a Worker, and returns the result. You can pass the Activity as either a lambda expression or a string Activity type name.

Standalone Activity execution with lambda expression in .NET

Example of executing a Standalone Activity with a lambda expression (type-safe): var result = await client.ExecuteActivityAsync(() => MyActivities.ComposeGreetingAsync(new ComposeGreetingInput("Hello", "World")), new("standalone-activity-id", "standalone-activity-sample") { ScheduleToCloseTimeout = TimeSpan.FromSeconds(10), });

Standalone Activity execution with string type name in .NET

Example of executing a Standalone Activity using a string Activity type name: var result = await client.ExecuteActivityAsync<string>("ComposeGreeting", new object?[] { new ComposeGreetingInput("Hello", "World") }, new("standalone-activity-id", "standalone-activity-sample") { ScheduleToCloseTimeout = TimeSpan.FromSeconds(10), });

StartActivityOptions required parameters for .NET

StartActivityOptions requires Id, TaskQueue, and at least one of ScheduleToCloseTimeout or StartToCloseTimeout. These are the minimum required parameters for executing a Standalone Activity in .NET.

.NET SDK version requirement for Standalone Activities

Temporal .NET SDK v1.12.0 or higher is required for Standalone Activities.

.NET version requirement for development

.NET 8.0 or higher is required for developing with the Temporal .NET SDK.

Temporal CLI for executing Standalone Activities

Standalone Activities can be executed using the Temporal CLI with the command: temporal activity execute --type ComposeGreeting --activity-id standalone-activity-id --task-queue standalone-activity-sample --schedule-to-close-timeout 10s --input '{"Greeting": "Hello", "Name": "World"}'

Give your agent this brain