-
Notifications
You must be signed in to change notification settings - Fork 319
Add docs for stand alone nexus operations #4430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
43640c5
3cf8772
14a5335
e65c292
4cc9816
d87b0b2
9583fc4
b140ec1
c8dd16b
eef8c08
73b8116
bf7aa3d
248fc98
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| --- | ||
| id: standalone-operations | ||
| title: Standalone Nexus Operations - .NET SDK | ||
| sidebar_label: Standalone Operations | ||
| toc_max_heading_level: 4 | ||
| keywords: | ||
| - standalone nexus operation | ||
| - nexus operation execution | ||
| - execute nexus operation | ||
| - nexus operation handle | ||
| - list nexus operations | ||
| - count nexus operations | ||
| - dotnet sdk | ||
| tags: | ||
| - Nexus | ||
| - Temporal Client | ||
| - .NET SDK | ||
| - Temporal SDKs | ||
| description: Execute Nexus Operations independently without a Workflow using the Temporal .NET SDK. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| --- | ||
|
|
||
| :::tip SUPPORT, STABILITY, and DEPENDENCY INFO | ||
|
|
||
| Temporal .NET SDK support for Standalone Nexus Operations is at | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| [Pre-release](/evaluate/development-production-features/release-stages#pre-release). | ||
|
|
||
| All APIs are experimental and may be subject to backwards-incompatible changes. | ||
|
|
||
| ::: | ||
|
|
||
| [Standalone Nexus Operations](/standalone-nexus-operation) let you run Nexus Operation Executions independently, without | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| being orchestrated by a Workflow. Instead of calling a Nexus Operation from within a Workflow Definition using | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| `Workflow.CreateNexusWorkflowClient<TService>()`, you execute a Standalone Nexus Operation directly from a Nexus Client | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| created using `ITemporalClient.CreateNexusClient<TService>()`. | ||
|
|
||
| Standalone Nexus Operations use the same Nexus Service contract, Operation handlers, and Worker setup as | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| Workflow-driven Operations — only the execution path differs. See the [Nexus feature guide](/develop/dotnet/nexus/feature-guide) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| for details on | ||
| [defining a Service contract](/develop/dotnet/nexus/feature-guide#define-nexus-service-contract), | ||
| [developing Operation handlers](/develop/dotnet/nexus/feature-guide#develop-nexus-service-operation-handlers), and | ||
| [registering a Service in a Worker](/develop/dotnet/nexus/feature-guide#register-a-nexus-service-in-a-worker). | ||
|
|
||
| This page focuses on the client-side APIs that are unique to Standalone Nexus Operations: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| - [Execute a Standalone Nexus Operation](#execute-operation) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| - [Get the result of a Standalone Nexus Operation](#get-operation-result) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| - [List Standalone Nexus Operations](#list-operations) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| - [Count Standalone Nexus Operations](#count-operations) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| ## Execute a Standalone Nexus Operation {#execute-operation} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 [vale] reported by reviewdog 🐶
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| To execute a Standalone Nexus Operation, first create a | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| [`NexusClient`](https://dotnet.temporal.io/api/Temporalio.Client.NexusClient.html) using | ||
| `ITemporalClient.CreateNexusClient<TService>()`, bound to a specific Nexus Endpoint and Service. The endpoint must be | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| pre-created on the server. Then call `ExecuteNexusOperationAsync()` from application code (for example, a starter | ||
| program), not from inside a Workflow Definition. | ||
|
|
||
| `ExecuteNexusOperationAsync` is a shortcut that starts the Operation and waits for the result. If you need a handle to | ||
| the Operation while it runs, call `StartNexusOperationAsync` instead — it returns a | ||
| [`NexusOperationHandle`](https://dotnet.temporal.io/api/Temporalio.Client.NexusOperationHandle.html) that you can use to | ||
| get the result, describe, cancel, or terminate the Operation. `Id` is required on | ||
| [`NexusOperationOptions`](https://dotnet.temporal.io/api/Temporalio.Client.NexusOperationOptions.html); | ||
| `ScheduleToCloseTimeout` is optional and defaults to the maximum allowed by the Temporal server. | ||
|
|
||
| ```csharp | ||
| var nexusClient = client.CreateNexusClient<IHelloService>("my-nexus-endpoint"); | ||
|
|
||
| var result = await nexusClient.ExecuteNexusOperationAsync( | ||
| svc => svc.Echo(new("Nexus Echo 👋")), | ||
| new("unique-operation-id") | ||
| { | ||
| ScheduleToCloseTimeout = TimeSpan.FromSeconds(10), | ||
| }); | ||
| ``` | ||
|
|
||
| You can also use the untyped overload that takes the Operation name as a string: | ||
|
|
||
| ```csharp | ||
| var nexusClient = client.CreateNexusClient("my-nexus-endpoint", "my-service-name"); | ||
|
|
||
| var handle = await nexusClient.StartNexusOperationAsync<IHelloService.EchoOutput>( | ||
| "Echo", | ||
| new IHelloService.EchoInput("Nexus Echo 👋"), | ||
| new("unique-operation-id") | ||
| { | ||
| ScheduleToCloseTimeout = TimeSpan.FromSeconds(10), | ||
| }); | ||
| ``` | ||
|
|
||
| ## Get the result of a Standalone Nexus Operation {#get-operation-result} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 [vale] reported by reviewdog 🐶
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| Use `NexusOperationHandle<TResult>.GetResultAsync()` to await the Operation's completion and retrieve its result. This | ||
| works for both synchronous and asynchronous (Workflow-backed) Operations. | ||
|
|
||
| ```csharp | ||
| var output = await handle.GetResultAsync(); | ||
| logger.LogInformation("Operation result: {Message}", output.Message); | ||
| ``` | ||
|
|
||
| If the Operation completed successfully, the result is deserialized into the handle's result type. If the Operation | ||
| failed, a `NexusOperationFailedException` is thrown. | ||
|
|
||
| You can also recover a handle for an already-started Operation using `GetNexusOperationHandle<TResult>()` on the | ||
| Temporal Client: | ||
|
|
||
| ```csharp | ||
| var handle = client.GetNexusOperationHandle<IHelloService.EchoOutput>("unique-operation-id"); | ||
| var output = await handle.GetResultAsync(); | ||
| ``` | ||
|
|
||
| ## List Standalone Nexus Operations {#list-operations} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 [vale] reported by reviewdog 🐶
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| Use [`ITemporalClient.ListNexusOperationsAsync()`](https://dotnet.temporal.io/api/Temporalio.Client.ITemporalClient.html#Temporalio_Client_ITemporalClient_ListNexusOperationsAsync_System_String_Temporalio_Client_NexusOperationListOptions_) | ||
| to list Standalone Nexus Operation Executions that match a [List Filter](/list-filter) query. The call returns an | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| `IAsyncEnumerable<NexusOperationExecution>` that you can iterate with `await foreach`. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| Note that `ListNexusOperationsAsync` is called on the base `ITemporalClient`, not on the `NexusClient`. | ||
|
|
||
| ```csharp | ||
| await foreach (var execution in client.ListNexusOperationsAsync( | ||
| "Endpoint = 'my-nexus-endpoint'")) | ||
| { | ||
| logger.LogInformation( | ||
| "OperationID: {Id}, Operation: {Operation}, Status: {Status}", | ||
| execution.OperationId, execution.Operation, execution.Status); | ||
| } | ||
| ``` | ||
|
|
||
| The query string accepts [List Filter](/list-filter) syntax. For example, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| `"Endpoint = 'my-endpoint' AND Status = 'Running'"`. | ||
|
|
||
| ## Count Standalone Nexus Operations {#count-operations} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 [vale] reported by reviewdog 🐶
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| Use [`ITemporalClient.CountNexusOperationsAsync()`](https://dotnet.temporal.io/api/Temporalio.Client.ITemporalClient.html#Temporalio_Client_ITemporalClient_CountNexusOperationsAsync_System_String_Temporalio_Client_NexusOperationCountOptions_) | ||
| to count Standalone Nexus Operation Executions that match a [List Filter](/list-filter) query. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| Note that `CountNexusOperationsAsync` is called on the base `ITemporalClient`, not on the `NexusClient`. | ||
|
|
||
| ```csharp | ||
| var count = await client.CountNexusOperationsAsync( | ||
| "Endpoint = 'my-nexus-endpoint'"); | ||
| logger.LogInformation("Total Nexus operations: {Count}", count.Count); | ||
| ``` | ||
|
|
||
| ## Run Standalone Nexus Operations with Temporal Cloud {#run-standalone-nexus-operations-temporal-cloud} | ||
|
|
||
| Standalone Nexus Operations work against Temporal Cloud with the same code — only the client connection options change. | ||
| For full details on connecting to Temporal Cloud, including Namespace creation, Nexus Endpoint setup, certificate | ||
| generation, and authentication options, see | ||
| [Make Nexus calls across Namespaces in Temporal Cloud](/develop/dotnet/nexus/feature-guide#nexus-calls-across-namespaces-temporal-cloud) | ||
| and [Connect to Temporal Cloud](/develop/dotnet/client/temporal-client#connect-to-temporal-cloud). | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| --- | ||
| id: standalone-operations | ||
| title: Standalone Nexus Operations - Go SDK | ||
| sidebar_label: Standalone Operations | ||
| toc_max_heading_level: 4 | ||
| keywords: | ||
| - standalone nexus operation | ||
| - nexus operation execution | ||
| - execute nexus operation | ||
| - nexus operation handle | ||
| - list nexus operations | ||
| - count nexus operations | ||
| - go sdk | ||
| tags: | ||
| - Nexus | ||
| - Temporal Client | ||
| - Go SDK | ||
| - Temporal SDKs | ||
| description: Execute Nexus Operations independently without a Workflow using the Temporal Go SDK. | ||
| --- | ||
|
|
||
| :::tip SUPPORT, STABILITY, and DEPENDENCY INFO | ||
|
|
||
| Temporal Go SDK support for Standalone Nexus Operations is at | ||
| [Pre-release](/evaluate/development-production-features/release-stages#pre-release). | ||
|
|
||
| All APIs are experimental and may be subject to backwards-incompatible changes. | ||
|
|
||
| ::: | ||
|
|
||
| [Standalone Nexus Operations](/standalone-nexus-operation) let you run Nexus Operation Executions independently, without | ||
| being orchestrated by a Workflow. Instead of calling a Nexus Operation from within a Workflow Definition using | ||
| `workflow.NewNexusClient()`, you execute a Standalone Nexus Operation directly from a Nexus Client created using | ||
| `client.NewNexusClient()`. | ||
|
|
||
| Standalone Nexus Operations use the same Nexus Service contract, Operation handlers, and Worker setup as | ||
| Workflow-driven Operations — only the execution path differs. See the [Nexus feature guide](/develop/go/nexus/feature-guide) for details on | ||
| [defining a Service contract](/develop/go/nexus/feature-guide#define-nexus-service-contract), | ||
| [developing Operation handlers](/develop/go/nexus/feature-guide#develop-nexus-service-operation-handlers), and | ||
| [registering a Service in a Worker](/develop/go/nexus/feature-guide#register-a-nexus-service-in-a-worker). | ||
|
Comment on lines
+37
to
+40
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm torn here on if we should suggest the quickstart or the feature guide here. I think either are fine, but maybe the quickstart would be nicer if someone has no idea about Nexus. |
||
|
|
||
| This page focuses on the client-side APIs that are unique to Standalone Nexus Operations: | ||
|
|
||
| - [Execute a Standalone Nexus Operation](#execute-operation) | ||
| - [Get the result of a Standalone Nexus Operation](#get-operation-result) | ||
| - [List Standalone Nexus Operations](#list-operations) | ||
| - [Count Standalone Nexus Operations](#count-operations) | ||
| - [Run Standalone Nexus Operations with Temporal Cloud](#run-standalone-nexus-operations-temporal-cloud) | ||
|
|
||
|
jsundai marked this conversation as resolved.
|
||
| :::note | ||
|
|
||
| This documentation uses source code from | ||
| [nexus-standalone-operations](https://github.com/temporalio/samples-go/tree/main/nexus-standalone-operations). | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the sample ready to merge? temporalio/samples-go#456 @Quinn-With-Two-Ns |
||
|
|
||
| ::: | ||
|
|
||
| ## Execute a Standalone Nexus Operation {/* #execute-operation */} | ||
|
|
||
| To execute a Standalone Nexus Operation, first create a | ||
| [`NexusClient`](https://pkg.go.dev/go.temporal.io/sdk/client#NexusClient) using `client.NewNexusClient()`, bound to a | ||
| specific Nexus Endpoint and Service. The endpoint must be pre-created on the server. Then call `ExecuteOperation()` from | ||
| application code (for example, a starter program), not from inside a Workflow Definition. | ||
|
|
||
| `ExecuteOperation` returns a [`NexusOperationHandle`](https://pkg.go.dev/go.temporal.io/sdk/client#NexusOperationHandle) | ||
| that you can use to get the result of the Operation. | ||
| [`StartNexusOperationOptions`](https://pkg.go.dev/go.temporal.io/sdk/client#StartNexusOperationOptions) requires `ID`. | ||
| `ScheduleToCloseTimeout` is optional and defaults to the maximum allowed by the Temporal server. | ||
|
|
||
| ```go | ||
| nexusClient, err := c.NewNexusClient(client.NexusClientOptions{ | ||
| Endpoint: "my-nexus-endpoint", | ||
| Service: "my-service-name", | ||
| }) | ||
|
|
||
| handle, err := nexusClient.ExecuteOperation(ctx, operationName, input, client.StartNexusOperationOptions{ | ||
| ID: "unique-operation-id", | ||
| ScheduleToCloseTimeout: 10 * time.Second, | ||
| }) | ||
| ``` | ||
|
|
||
| See the full | ||
| [starter sample](https://github.com/temporalio/samples-go/blob/main/nexus-standalone-operations/starter/main.go) | ||
| for a complete example that executes both synchronous and asynchronous Operations, gets their results, and lists and | ||
| counts Operations. | ||
|
|
||
| To run the starter (in a separate terminal from the Worker): | ||
|
|
||
| ``` | ||
| go run nexus-standalone-operations/starter/main.go | ||
| ``` | ||
|
|
||
| ## Get the result of a Standalone Nexus Operation {/* #get-operation-result */} | ||
|
|
||
| Use `NexusOperationHandle.Get()` to block until the Operation completes and retrieve its result. This works for both | ||
| synchronous and asynchronous (Workflow-backed) Operations. | ||
|
|
||
| ```go | ||
| var result service.EchoOutput | ||
| err = handle.Get(context.Background(), &result) | ||
| if err != nil { | ||
| log.Fatalln("Operation failed", err) | ||
| } | ||
| log.Println("Operation result:", result.Message) | ||
| ``` | ||
|
|
||
| If the Operation completed successfully, the result is deserialized into the provided pointer. If the Operation failed, | ||
| the failure is returned as an error. | ||
|
|
||
| ## List Standalone Nexus Operations {/* #list-operations */} | ||
|
|
||
| Use [`client.ListNexusOperations()`](https://pkg.go.dev/go.temporal.io/sdk/client#Client) to list Standalone Nexus | ||
| Operation Executions that match a [List Filter](/list-filter) query. The result contains an iterator that yields | ||
| operation metadata entries. | ||
|
|
||
| Note that `ListNexusOperations` is called on the base `client.Client`, not on the `NexusClient`. | ||
|
|
||
| ```go | ||
| resp, err := c.ListNexusOperations(context.Background(), client.ListNexusOperationsOptions{ | ||
| Query: "Endpoint = 'my-nexus-endpoint'", | ||
| }) | ||
| if err != nil { | ||
| log.Fatalln("Unable to list Nexus operations", err) | ||
| } | ||
|
|
||
| for metadata, err := range resp.Results { | ||
| if err != nil { | ||
| log.Fatalln("Error iterating operations", err) | ||
| } | ||
| log.Printf("OperationID: %s, Operation: %s, Status: %v\n", | ||
| metadata.OperationID, metadata.Operation, metadata.Status) | ||
| } | ||
| ``` | ||
|
|
||
| The `Query` field accepts [List Filter](/list-filter) syntax. For example, | ||
| `"Endpoint = 'my-endpoint' AND Status = 'Running'"`. | ||
|
|
||
| ## Count Standalone Nexus Operations {/* #count-operations */} | ||
|
|
||
| Use [`client.CountNexusOperations()`](https://pkg.go.dev/go.temporal.io/sdk/client#Client) to count Standalone Nexus | ||
| Operation Executions that match a [List Filter](/list-filter) query. | ||
|
|
||
| Note that `CountNexusOperations` is called on the base `client.Client`, not on the `NexusClient`. | ||
|
|
||
| ```go | ||
| resp, err := c.CountNexusOperations(context.Background(), client.CountNexusOperationsOptions{ | ||
| Query: "Endpoint = 'my-nexus-endpoint'", | ||
| }) | ||
| if err != nil { | ||
| log.Fatalln("Unable to count Nexus operations", err) | ||
| } | ||
|
|
||
| log.Println("Total Nexus operations:", resp.Count) | ||
| ``` | ||
|
|
||
| ## Run Standalone Nexus Operations with Temporal Cloud {/* #run-standalone-nexus-operations-temporal-cloud */} | ||
|
|
||
| The code samples on this page use `envconfig.MustLoadDefaultClientOptions()`, so the same code | ||
| works against Temporal Cloud — just configure the connection via environment variables or a TOML | ||
| profile. No code changes are needed. | ||
|
|
||
| For full details on connecting to Temporal Cloud, including Namespace creation, Nexus Endpoint | ||
| setup, certificate generation, and authentication options, see | ||
| [Make Nexus calls across Namespaces in Temporal Cloud](/develop/go/nexus/feature-guide#nexus-calls-across-namespaces-temporal-cloud) | ||
| and [Connect to Temporal Cloud](/develop/go/client/temporal-client#connect-to-temporal-cloud). | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Temporal.terms] Use 'Temporal Nexus' instead of 'Nexus' when referring to a Temporal term.