@@ -14,25 +14,30 @@ import (
1414 "github.com/temporalio/samples-go/nexus/service"
1515)
1616
17- // NewSyncOperation is a meant for exposing simple RPC handlers.
18- var EchoOperation = temporalnexus .NewSyncOperation (service .EchoOperationName , func (ctx context.Context , c client.Client , input service.EchoInput , options nexus.StartOperationOptions ) (service.EchoOutput , error ) {
19- // The method is provided with an SDK client that can be used for arbitrary calls such as signaling, querying,
20- // and listing workflows but implementations are free to make arbitrary calls to other services or databases, or
21- // perform simple computations such as this one.
22- return service .EchoOutput (input ), nil
23- })
17+ // NewSyncOperation is meant for exposing simple RPC handlers.
18+ var EchoOperation = temporalnexus .NewSyncOperation (
19+ service .EchoOperationName ,
20+ func (ctx context.Context , c client.Client , input service.EchoInput , options nexus.StartOperationOptions ) (service.EchoOutput , error ) {
21+ // The method is provided with an SDK client that can be used for arbitrary calls such as signaling, querying,
22+ // and listing workflows but implementations are free to make arbitrary calls to other services or databases, or
23+ // perform simple computations such as this one.
24+ return service .EchoOutput (input ), nil
25+ })
2426
2527// Use the NewWorkflowRunOperation constructor, which is the easiest way to expose a workflow as an operation.
2628// See alternatives at https://pkg.go.dev/go.temporal.io/sdk/temporalnexus.
27- var HelloOperation = temporalnexus .NewWorkflowRunOperation (service .HelloOperationName , HelloHandlerWorkflow , func (ctx context.Context , input service.HelloInput , options nexus.StartOperationOptions ) (client.StartWorkflowOptions , error ) {
28- return client.StartWorkflowOptions {
29- // Workflow IDs should typically be business meaningful IDs and are used to dedupe workflow starts.
30- // For this example, we're using the request ID allocated by Temporal when the caller workflow schedules
31- // the operation, this ID is guaranteed to be stable across retries of this operation.
32- ID : options .RequestID ,
33- // Task queue defaults to the task queue this operation is handled on.
34- }, nil
35- })
29+ var HelloOperation = temporalnexus .NewWorkflowRunOperation (
30+ service .HelloOperationName ,
31+ HelloHandlerWorkflow ,
32+ func (ctx context.Context , input service.HelloInput , options nexus.StartOperationOptions ) (client.StartWorkflowOptions , error ) {
33+ return client.StartWorkflowOptions {
34+ // Workflow IDs should typically be business meaningful IDs and are used to dedupe workflow starts.
35+ // For this example, we're using the request ID allocated by Temporal when the caller workflow schedules
36+ // the operation, this ID is guaranteed to be stable across retries of this operation.
37+ ID : options .RequestID ,
38+ // Task queue defaults to the task queue this operation is handled on.
39+ }, nil
40+ })
3641
3742func HelloHandlerWorkflow (_ workflow.Context , input service.HelloInput ) (service.HelloOutput , error ) {
3843 switch input .Language {
@@ -49,4 +54,5 @@ func HelloHandlerWorkflow(_ workflow.Context, input service.HelloInput) (service
4954 }
5055 return service.HelloOutput {}, fmt .Errorf ("unsupported language %q" , input .Language )
5156}
52- // @@@SNIPEND
57+
58+ // @@@SNIPEND
0 commit comments