@@ -7,13 +7,15 @@ import (
77 "time"
88
99 enumspb "go.temporal.io/api/enums/v1"
10+ workflowservicepb "go.temporal.io/api/workflowservice/v1"
1011 "go.temporal.io/sdk/client"
1112 "go.temporal.io/sdk/workflow"
1213 "golang.org/x/sync/errgroup"
1314)
1415
1516type ClientActionsExecutor struct {
1617 Client client.Client
18+ Namespace string
1719 WorkflowOptions client.StartWorkflowOptions
1820 WorkflowType string
1921 WorkflowInput * WorkflowInput
@@ -127,6 +129,8 @@ func (e *ClientActionsExecutor) executeClientAction(ctx context.Context, action
127129 } else if action .GetNestedActions () != nil {
128130 err = e .executeClientActionSet (ctx , action .GetNestedActions ())
129131 return err
132+ } else if sano := action .GetDoStandaloneNexusOperation (); sano != nil {
133+ return e .executeStandaloneNexusOperation (ctx , sano )
130134 } else {
131135 return fmt .Errorf ("client action must be set" )
132136 }
@@ -196,3 +200,32 @@ func (e *ClientActionsExecutor) executeUpdateAction(ctx context.Context, upd *Do
196200 }
197201 return run , err
198202}
203+
204+ func (e * ClientActionsExecutor ) executeStandaloneNexusOperation (ctx context.Context , sno * DoStandaloneNexusOperation ) error {
205+ // Use a unique operation ID scoped to the workflow so parallel iterations don't collide.
206+ operationID := fmt .Sprintf ("standalone-nexus-%s" , e .WorkflowOptions .ID )
207+ _ , err := e .Client .WorkflowService ().StartNexusOperationExecution (ctx ,
208+ & workflowservicepb.StartNexusOperationExecutionRequest {
209+ Namespace : e .Namespace ,
210+ OperationId : operationID ,
211+ Endpoint : sno .Endpoint ,
212+ Service : sno .Service ,
213+ Operation : sno .Operation ,
214+ })
215+ if err != nil {
216+ return fmt .Errorf ("StartNexusOperationExecution: %w" , err )
217+ }
218+ pollResp , err := e .Client .WorkflowService ().PollNexusOperationExecution (ctx ,
219+ & workflowservicepb.PollNexusOperationExecutionRequest {
220+ Namespace : e .Namespace ,
221+ OperationId : operationID ,
222+ WaitStage : enumspb .NEXUS_OPERATION_WAIT_STAGE_CLOSED ,
223+ })
224+ if err != nil {
225+ return fmt .Errorf ("PollNexusOperationExecution: %w" , err )
226+ }
227+ if failure := pollResp .GetFailure (); failure != nil {
228+ return fmt .Errorf ("standalone nexus operation failed: %s" , failure .GetMessage ())
229+ }
230+ return nil
231+ }
0 commit comments