From 0ca798ae574ee512020e449d6dcd6f0c1241b02c Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Tue, 3 Dec 2024 19:03:15 -0500 Subject: [PATCH] Combine parameters in a single struct --- client/client.go | 23 ++-- internal/client.go | 17 ++- internal/internal_workflow_client.go | 23 ++-- internal/internal_workflow_client_test.go | 77 +++++++++----- internal/nexus_operations.go | 2 +- mocks/Client.go | 18 ++-- test/integration_test.go | 123 ++++++++++++++-------- 7 files changed, 183 insertions(+), 100 deletions(-) diff --git a/client/client.go b/client/client.go index 6bf427df4..9db5c14be 100644 --- a/client/client.go +++ b/client/client.go @@ -162,8 +162,8 @@ type ( // StartWorkflowOptions configuration parameters for starting a workflow execution. StartWorkflowOptions = internal.StartWorkflowOptions - // WithStartWorkflowOperation defines how to start a workflow when using Update-With-Start. - // See [Client.NewWithStartWorkflowOperation] for details. + // WithStartWorkflowOperation defines how to start a workflow when using update-with-start. + // See [Client.NewWithStartWorkflowOperation] and [Client.UpdateWithStartWorkflow]. // NOTE: Experimental WithStartWorkflowOperation = internal.WithStartWorkflowOperation @@ -274,6 +274,11 @@ type ( // NOTE: Experimental UpdateWorkflowOptions = internal.UpdateWorkflowOptions + // UpdateWithStartWorkflowOptions encapsulates the parameters for update-with-start. + // See [Client.UpdateWithStartWorkflow]. + // NOTE: Experimental + UpdateWithStartWorkflowOptions = internal.UpdateWithStartWorkflowOptions + // WorkflowUpdateHandle represents a running or completed workflow // execution update and gives the holder access to the outcome of the same. // NOTE: Experimental @@ -559,8 +564,8 @@ type ( SignalWithStartWorkflow(ctx context.Context, workflowID string, signalName string, signalArg interface{}, options StartWorkflowOptions, workflow interface{}, workflowArgs ...interface{}) (WorkflowRun, error) - // NewWithStartWorkflowOperation returns a WithStartWorkflowOperation to perform Update-with-Start. - // Returns an error if the WorkflowIDConflictPolicy is not set, or if the workflow or arguments are invalid. + // NewWithStartWorkflowOperation returns a WithStartWorkflowOperation to perform update-with-start. + // See [Client.UpdateWithStartWorkflow]. // NOTE: Experimental NewWithStartWorkflowOperation(options StartWorkflowOptions, workflow interface{}, args ...interface{}) WithStartWorkflowOperation @@ -840,10 +845,16 @@ type ( // NOTE: Experimental UpdateWorkflow(ctx context.Context, options UpdateWorkflowOptions) (WorkflowUpdateHandle, error) - // UpdateWithStartWorkflow intercepts client.Client.UpdateWithStartWorkflow. + // UpdateWithStartWorkflow issues an update-with-start request. A + // WorkflowIDConflictPolicy must be set. If the specified workflow is + // not running, then a new workflow execution is started and the update + // is sent in the first workflow task. Alternatively if the specified + // workflow is running then, if the WorkflowIDConflictPolicy is + // USE_EXISTING, the update is issued against the specified workflow, + // and if the WorkflowIDConflictPolicy is FAIL, an error is returned. // // NOTE: Experimental - UpdateWithStartWorkflow(ctx context.Context, options UpdateWorkflowOptions, startOperation WithStartWorkflowOperation) (WorkflowUpdateHandle, error) + UpdateWithStartWorkflow(ctx context.Context, options UpdateWithStartWorkflowOptions) (WorkflowUpdateHandle, error) // GetWorkflowUpdateHandle creates a handle to the referenced update // which can be polled for an outcome. Note that runID is optional and diff --git a/internal/client.go b/internal/client.go index 02472899b..d54092e26 100644 --- a/internal/client.go +++ b/internal/client.go @@ -134,7 +134,7 @@ type ( SignalWithStartWorkflow(ctx context.Context, workflowID string, signalName string, signalArg interface{}, options StartWorkflowOptions, workflow interface{}, workflowArgs ...interface{}) (WorkflowRun, error) - // NewWithStartWorkflowOperation returns a WithStartWorkflowOperation to perform Update-with-Start. + // NewWithStartWorkflowOperation returns a WithStartWorkflowOperation for use in UpdateWithStartWorkflow. // NOTE: Experimental NewWithStartWorkflowOperation(options StartWorkflowOptions, workflow interface{}, args ...interface{}) WithStartWorkflowOperation @@ -397,9 +397,16 @@ type ( // NOTE: Experimental UpdateWorkflow(ctx context.Context, options UpdateWorkflowOptions) (WorkflowUpdateHandle, error) - // UpdateWithStartWorkflow issues an update request to the specified workflow execution, starting the workflow if appropriate. + // UpdateWithStartWorkflow issues an update-with-start request. A + // WorkflowIDConflictPolicy must be set. If the specified workflow is + // not running, then a new workflow execution is started and the update + // is sent in the first workflow task. Alternatively if the specified + // workflow is running then, if the WorkflowIDConflictPolicy is + // USE_EXISTING, the update is issued against the specified workflow, + // and if the WorkflowIDConflictPolicy is FAIL, an error is returned. + // // NOTE: Experimental - UpdateWithStartWorkflow(ctx context.Context, options UpdateWorkflowOptions, startOperation WithStartWorkflowOperation) (WorkflowUpdateHandle, error) + UpdateWithStartWorkflow(ctx context.Context, options UpdateWithStartWorkflowOptions) (WorkflowUpdateHandle, error) // GetWorkflowUpdateHandle creates a handle to the referenced update // which can be polled for an outcome. Note that runID is optional and @@ -746,8 +753,8 @@ type ( links []*commonpb.Link } - // WithStartWorkflowOperation defines how to start a workflow when using Update-With-Start. - // See NewWithStartWorkflowOperation for details. + // WithStartWorkflowOperation defines how to start a workflow when using update-with-start. + // See [NewWithStartWorkflowOperation] and [UpdateWithStartWorkflow]. // NOTE: Experimental WithStartWorkflowOperation interface { Get(ctx context.Context) (WorkflowRun, error) diff --git a/internal/internal_workflow_client.go b/internal/internal_workflow_client.go index 4ad22144d..7490b4fe7 100644 --- a/internal/internal_workflow_client.go +++ b/internal/internal_workflow_client.go @@ -357,7 +357,7 @@ func (wc *WorkflowClient) SignalWithStartWorkflow(ctx context.Context, workflowI func (wc *WorkflowClient) NewWithStartWorkflowOperation(options StartWorkflowOptions, workflow interface{}, args ...interface{}) WithStartWorkflowOperation { op := &WithStartWorkflowOperationImpl{doneCh: make(chan struct{})} if options.WorkflowIDConflictPolicy == enumspb.WORKFLOW_ID_CONFLICT_POLICY_UNSPECIFIED { - op.err = errors.New("WorkflowIDConflictPolicy must be set in StartWorkflowOptions for Update-With-Start") + op.err = errors.New("WorkflowIDConflictPolicy must be set in StartWorkflowOptions for update-with-start") return op } input, err := createStartWorkflowInput(options, workflow, args, wc.registry) @@ -803,6 +803,14 @@ type UpdateWorkflowOptions struct { FirstExecutionRunID string } +// UpdateWithStartWorkflowOptions encapsulates the parameters for update-with-start. +// See [UpdateWithStartWorkflow]. +// NOTE: Experimental +type UpdateWithStartWorkflowOptions struct { + StartOperation WithStartWorkflowOperation + UpdateOptions UpdateWorkflowOptions +} + // WorkflowUpdateHandle is a handle to a workflow execution update process. The // update may or may not have completed so an instance of this type functions // similar to a Future with respect to the outcome of the update. If the update @@ -1180,10 +1188,9 @@ func (wc *WorkflowClient) UpdateWorkflow( func (wc *WorkflowClient) UpdateWithStartWorkflow( ctx context.Context, - updateOptions UpdateWorkflowOptions, - startOperation WithStartWorkflowOperation, + options UpdateWithStartWorkflowOptions, ) (WorkflowUpdateHandle, error) { - startOp, ok := startOperation.(*WithStartWorkflowOperationImpl) + startOp, ok := options.StartOperation.(*WithStartWorkflowOperationImpl) if !ok { panic("startOperation must be created by NewWithStartWorkflowOperation") } @@ -1193,21 +1200,21 @@ func (wc *WorkflowClient) UpdateWithStartWorkflow( if err := wc.ensureInitialized(ctx); err != nil { return nil, err } - if updateOptions.RunID != "" { + if options.UpdateOptions.RunID != "" { return nil, errors.New("invalid UpdateWorkflowOptions: RunID cannot be set for UpdateWithStartWorkflow because the workflow might not be running") } - if updateOptions.FirstExecutionRunID != "" { + if options.UpdateOptions.FirstExecutionRunID != "" { return nil, errors.New("invalid UpdateWorkflowOptions: FirstExecutionRunID cannot be set for UpdateWithStartWorkflow because the workflow might not be running") } - updateInput, err := createUpdateWorkflowInput(updateOptions) + updateInput, err := createUpdateWorkflowInput(options.UpdateOptions) if err != nil { return nil, err } ctx = contextWithNewHeader(ctx) - return wc.interceptor.UpdateWithStartWorkflow(ctx, updateInput, startOperation) + return wc.interceptor.UpdateWithStartWorkflow(ctx, updateInput, startOp) } // CheckHealthRequest is a request for Client.CheckHealth. diff --git a/internal/internal_workflow_client_test.go b/internal/internal_workflow_client_test.go index 397dc128c..85b1b48cd 100644 --- a/internal/internal_workflow_client_test.go +++ b/internal/internal_workflow_client_test.go @@ -1020,10 +1020,13 @@ func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_Retry() { _, err := s.workflowClient.UpdateWithStartWorkflow( context.Background(), - UpdateWorkflowOptions{ - UpdateName: "update", - WaitForStage: WorkflowUpdateStageCompleted, - }, startOp, + UpdateWithStartWorkflowOptions{ + UpdateOptions: UpdateWorkflowOptions{ + UpdateName: "update", + WaitForStage: WorkflowUpdateStageCompleted, + }, + StartOperation: startOp, + }, ) s.NoError(err) } @@ -1094,10 +1097,13 @@ func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_Abort() { _, err := s.workflowClient.UpdateWithStartWorkflow( ctxWithTimeout, - UpdateWorkflowOptions{ - UpdateName: "update", - WaitForStage: WorkflowUpdateStageCompleted, - }, startOp, + UpdateWithStartWorkflowOptions{ + UpdateOptions: UpdateWorkflowOptions{ + UpdateName: "update", + WaitForStage: WorkflowUpdateStageCompleted, + }, + StartOperation: startOp, + }, ) var expectedErr *WorkflowUpdateServiceTimeoutOrCanceledError @@ -1122,10 +1128,13 @@ func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_NonMultiOperationError( _, err := s.workflowClient.UpdateWithStartWorkflow( context.Background(), - UpdateWorkflowOptions{ - UpdateName: "update", - WaitForStage: WorkflowUpdateStageCompleted, - }, startOp, + UpdateWithStartWorkflowOptions{ + UpdateOptions: UpdateWorkflowOptions{ + UpdateName: "update", + WaitForStage: WorkflowUpdateStageCompleted, + }, + StartOperation: startOp, + }, ) s.ErrorContains(err, "internal error") } @@ -1147,10 +1156,13 @@ func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_ServerResponseCountMism _, err := s.workflowClient.UpdateWithStartWorkflow( context.Background(), - UpdateWorkflowOptions{ - UpdateName: "update", - WaitForStage: WorkflowUpdateStageCompleted, - }, startOp, + UpdateWithStartWorkflowOptions{ + UpdateOptions: UpdateWorkflowOptions{ + UpdateName: "update", + WaitForStage: WorkflowUpdateStageCompleted, + }, + StartOperation: startOp, + }, ) s.ErrorContains(err, "invalid server response: 0 instead of 2 operation results") } @@ -1170,10 +1182,13 @@ func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_ServerErrorResponseCoun _, err := s.workflowClient.UpdateWithStartWorkflow( context.Background(), - UpdateWorkflowOptions{ - UpdateName: "update", - WaitForStage: WorkflowUpdateStageCompleted, - }, startOp, + UpdateWithStartWorkflowOptions{ + UpdateOptions: UpdateWorkflowOptions{ + UpdateName: "update", + WaitForStage: WorkflowUpdateStageCompleted, + }, + StartOperation: startOp, + }, ) s.ErrorContains(err, "invalid server response: 0 instead of 2 operation errors") } @@ -1200,10 +1215,13 @@ func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_ServerStartResponseType _, err := s.workflowClient.UpdateWithStartWorkflow( context.Background(), - UpdateWorkflowOptions{ - UpdateName: "update", - WaitForStage: WorkflowUpdateStageCompleted, - }, startOp, + UpdateWithStartWorkflowOptions{ + UpdateOptions: UpdateWorkflowOptions{ + UpdateName: "update", + WaitForStage: WorkflowUpdateStageCompleted, + }, + StartOperation: startOp, + }, ) s.ErrorContains(err, "invalid server response: StartWorkflow response has the wrong type *workflowservice.ExecuteMultiOperationResponse_Response_UpdateWorkflow") } @@ -1236,10 +1254,13 @@ func (s *workflowRunSuite) TestExecuteWorkflowWithUpdate_ServerUpdateResponseTyp _, err := s.workflowClient.UpdateWithStartWorkflow( context.Background(), - UpdateWorkflowOptions{ - UpdateName: "update", - WaitForStage: WorkflowUpdateStageCompleted, - }, startOp, + UpdateWithStartWorkflowOptions{ + UpdateOptions: UpdateWorkflowOptions{ + UpdateName: "update", + WaitForStage: WorkflowUpdateStageCompleted, + }, + StartOperation: startOp, + }, ) s.ErrorContains(err, "invalid server response: UpdateWorkflow response has the wrong type *workflowservice.ExecuteMultiOperationResponse_Response_StartWorkflow") } diff --git a/internal/nexus_operations.go b/internal/nexus_operations.go index 1d2c69fc6..6a73e6fc8 100644 --- a/internal/nexus_operations.go +++ b/internal/nexus_operations.go @@ -384,7 +384,7 @@ func (t *testSuiteClientForNexusOperations) UpdateWorkflow(ctx context.Context, } // UpdateWithStartWorkflow implements Client. -func (t *testSuiteClientForNexusOperations) UpdateWithStartWorkflow(ctx context.Context, options UpdateWorkflowOptions, startOperation WithStartWorkflowOperation) (WorkflowUpdateHandle, error) { +func (t *testSuiteClientForNexusOperations) UpdateWithStartWorkflow(ctx context.Context, options UpdateWithStartWorkflowOptions) (WorkflowUpdateHandle, error) { panic("unimplemented in the test environment") } diff --git a/mocks/Client.go b/mocks/Client.go index 63c147a78..8b0ee7233 100644 --- a/mocks/Client.go +++ b/mocks/Client.go @@ -901,9 +901,9 @@ func (_m *Client) TerminateWorkflow(ctx context.Context, workflowID string, runI return r0 } -// UpdateWithStartWorkflow provides a mock function with given fields: ctx, options, startOperation -func (_m *Client) UpdateWithStartWorkflow(ctx context.Context, options client.UpdateWorkflowOptions, startOperation client.WithStartWorkflowOperation) (client.WorkflowUpdateHandle, error) { - ret := _m.Called(ctx, options, startOperation) +// UpdateWithStartWorkflow provides a mock function with given fields: ctx, options +func (_m *Client) UpdateWithStartWorkflow(ctx context.Context, options client.UpdateWithStartWorkflowOptions) (client.WorkflowUpdateHandle, error) { + ret := _m.Called(ctx, options) if len(ret) == 0 { panic("no return value specified for UpdateWithStartWorkflow") @@ -911,19 +911,19 @@ func (_m *Client) UpdateWithStartWorkflow(ctx context.Context, options client.Up var r0 client.WorkflowUpdateHandle var r1 error - if rf, ok := ret.Get(0).(func(context.Context, client.UpdateWorkflowOptions, client.WithStartWorkflowOperation) (client.WorkflowUpdateHandle, error)); ok { - return rf(ctx, options, startOperation) + if rf, ok := ret.Get(0).(func(context.Context, client.UpdateWithStartWorkflowOptions) (client.WorkflowUpdateHandle, error)); ok { + return rf(ctx, options) } - if rf, ok := ret.Get(0).(func(context.Context, client.UpdateWorkflowOptions, client.WithStartWorkflowOperation) client.WorkflowUpdateHandle); ok { - r0 = rf(ctx, options, startOperation) + if rf, ok := ret.Get(0).(func(context.Context, client.UpdateWithStartWorkflowOptions) client.WorkflowUpdateHandle); ok { + r0 = rf(ctx, options) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(client.WorkflowUpdateHandle) } } - if rf, ok := ret.Get(1).(func(context.Context, client.UpdateWorkflowOptions, client.WithStartWorkflowOperation) error); ok { - r1 = rf(ctx, options, startOperation) + if rf, ok := ret.Get(1).(func(context.Context, client.UpdateWithStartWorkflowOptions) error); ok { + r1 = rf(ctx, options) } else { r1 = ret.Error(1) } diff --git a/test/integration_test.go b/test/integration_test.go index 08f7fdddf..4890d38fa 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -3998,11 +3998,14 @@ func (ts *IntegrationTestSuite) TestUpdateWithStartWorkflow() { startOp := ts.client.NewWithStartWorkflowOperation( startWorkflowOptions(), ts.workflows.UpdateEntityWorkflow, ) - updHandle, err := ts.client.UpdateWithStartWorkflow(ctx, client.UpdateWorkflowOptions{ - UpdateName: "update", - Args: []any{1}, - WaitForStage: client.WorkflowUpdateStageAccepted, - }, startOp) + updHandle, err := ts.client.UpdateWithStartWorkflow(ctx, client.UpdateWithStartWorkflowOptions{ + UpdateOptions: client.UpdateWorkflowOptions{ + UpdateName: "update", + Args: []any{1}, + WaitForStage: client.WorkflowUpdateStageAccepted, + }, + StartOperation: startOp, + }) ts.NoError(err) println(updHandle) @@ -4026,11 +4029,14 @@ func (ts *IntegrationTestSuite) TestUpdateWithStartWorkflow() { startOptions.WorkflowIDConflictPolicy = enumspb.WORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING startOp := ts.client.NewWithStartWorkflowOperation(startOptions, ts.workflows.UpdateEntityWorkflow) - updHandle, err := ts.client.UpdateWithStartWorkflow(ctx, client.UpdateWorkflowOptions{ - UpdateName: "update", - Args: []any{1}, - WaitForStage: client.WorkflowUpdateStageCompleted, - }, startOp) + updHandle, err := ts.client.UpdateWithStartWorkflow(ctx, client.UpdateWithStartWorkflowOptions{ + UpdateOptions: client.UpdateWorkflowOptions{ + UpdateName: "update", + Args: []any{1}, + WaitForStage: client.WorkflowUpdateStageCompleted, + }, + StartOperation: startOp, + }) ts.NoError(err) run2, err := startOp.Get(ctx) @@ -4045,11 +4051,14 @@ func (ts *IntegrationTestSuite) TestUpdateWithStartWorkflow() { ts.Run("sends update-with-start but update is rejected", func() { startOp := ts.client.NewWithStartWorkflowOperation(startWorkflowOptions(), ts.workflows.UpdateEntityWorkflow) - updHandle, err := ts.client.UpdateWithStartWorkflow(ctx, client.UpdateWorkflowOptions{ - UpdateName: "update", - Args: []any{-1}, // rejected update payload - WaitForStage: client.WorkflowUpdateStageCompleted, - }, startOp) + updHandle, err := ts.client.UpdateWithStartWorkflow(ctx, client.UpdateWithStartWorkflowOptions{ + UpdateOptions: client.UpdateWorkflowOptions{ + UpdateName: "update", + Args: []any{-1}, // rejected update payload + WaitForStage: client.WorkflowUpdateStageCompleted, + }, + StartOperation: startOp, + }) ts.NoError(err) run, err := startOp.Get(ctx) @@ -4074,12 +4083,14 @@ func (ts *IntegrationTestSuite) TestUpdateWithStartWorkflow() { done1 <- struct{}{} }() - updHandle, err := ts.client.UpdateWithStartWorkflow(ctx, - client.UpdateWorkflowOptions{ + updHandle, err := ts.client.UpdateWithStartWorkflow(ctx, client.UpdateWithStartWorkflowOptions{ + UpdateOptions: client.UpdateWorkflowOptions{ UpdateName: "update", Args: []any{1}, WaitForStage: client.WorkflowUpdateStageAccepted, - }, startOp) + }, + StartOperation: startOp, + }) ts.NoError(err) done2 := make(chan struct{}) @@ -4105,12 +4116,18 @@ func (ts *IntegrationTestSuite) TestUpdateWithStartWorkflow() { startOptions.CronSchedule = "invalid!" startOp := ts.client.NewWithStartWorkflowOperation(startOptions, ts.workflows.UpdateEntityWorkflow) - _, err := ts.client.UpdateWithStartWorkflow(ctx, updateOptions, startOp) + _, err := ts.client.UpdateWithStartWorkflow(ctx, client.UpdateWithStartWorkflowOptions{ + UpdateOptions: updateOptions, + StartOperation: startOp, + }) ts.Error(err) startOptions.WorkflowIDConflictPolicy = enumspb.WORKFLOW_ID_CONFLICT_POLICY_UNSPECIFIED startOp = ts.client.NewWithStartWorkflowOperation(startOptions, ts.workflows.UpdateEntityWorkflow) - _, err = ts.client.UpdateWithStartWorkflow(ctx, updateOptions, startOp) + _, err = ts.client.UpdateWithStartWorkflow(ctx, client.UpdateWithStartWorkflowOptions{ + UpdateOptions: updateOptions, + StartOperation: startOp, + }) ts.ErrorContains(err, "WorkflowIDConflictPolicy must be set") }) @@ -4119,39 +4136,49 @@ func (ts *IntegrationTestSuite) TestUpdateWithStartWorkflow() { startOp := ts.client.NewWithStartWorkflowOperation(startOptions, ts.workflows.UpdateEntityWorkflow) - _, err := ts.client.UpdateWithStartWorkflow(ctx, - client.UpdateWorkflowOptions{ + _, err := ts.client.UpdateWithStartWorkflow(ctx, client.UpdateWithStartWorkflowOptions{ + UpdateOptions: client.UpdateWorkflowOptions{ // invalid - }, startOp) + }, + StartOperation: startOp, + }) ts.ErrorContains(err, "WaitForStage must be specified") - _, err = ts.client.UpdateWithStartWorkflow(ctx, - client.UpdateWorkflowOptions{ + _, err = ts.client.UpdateWithStartWorkflow(ctx, client.UpdateWithStartWorkflowOptions{ + UpdateOptions: client.UpdateWorkflowOptions{ RunID: "invalid", WaitForStage: client.WorkflowUpdateStageCompleted, - }, startOp) + }, + StartOperation: startOp, + }) ts.ErrorContains(err, "invalid UpdateWorkflowOptions: RunID cannot be set for UpdateWithStartWorkflow because the workflow might not be running") - _, err = ts.client.UpdateWithStartWorkflow(ctx, - client.UpdateWorkflowOptions{ + _, err = ts.client.UpdateWithStartWorkflow(ctx, client.UpdateWithStartWorkflowOptions{ + UpdateOptions: client.UpdateWorkflowOptions{ FirstExecutionRunID: "invalid", WaitForStage: client.WorkflowUpdateStageCompleted, - }, startOp) + }, + StartOperation: startOp, + }) ts.ErrorContains(err, "invalid UpdateWorkflowOptions: FirstExecutionRunID cannot be set for UpdateWithStartWorkflow because the workflow might not be running") - _, err = ts.client.UpdateWithStartWorkflow(ctx, - client.UpdateWorkflowOptions{ + _, err = ts.client.UpdateWithStartWorkflow(ctx, client.UpdateWithStartWorkflowOptions{ + UpdateOptions: client.UpdateWorkflowOptions{ UpdateName: "", // invalid WaitForStage: client.WorkflowUpdateStageCompleted, - }, startOp) + }, + StartOperation: startOp, + }) ts.ErrorContains(err, "invalid WithStartWorkflowOperation: ") // omitting server message intentionally - _, err = ts.client.UpdateWithStartWorkflow(ctx, - client.UpdateWorkflowOptions{ + _, err = ts.client.UpdateWithStartWorkflow(ctx, client.UpdateWithStartWorkflowOptions{ + UpdateOptions: client.UpdateWorkflowOptions{ WorkflowID: "different", // does not match Start's UpdateName: "update", WaitForStage: client.WorkflowUpdateStageCompleted, - }, startOp) + }, + StartOperation: startOp, + }) ts.ErrorContains(err, "invalid WithStartWorkflowOperation: ") // omitting server message intentionally }) @@ -4161,12 +4188,14 @@ func (ts *IntegrationTestSuite) TestUpdateWithStartWorkflow() { ts.NoError(err) startOp := ts.client.NewWithStartWorkflowOperation(startOptions, ts.workflows.UpdateEntityWorkflow) - _, err = ts.client.UpdateWithStartWorkflow(ctx, - client.UpdateWorkflowOptions{ + _, err = ts.client.UpdateWithStartWorkflow(ctx, client.UpdateWithStartWorkflowOptions{ + UpdateOptions: client.UpdateWorkflowOptions{ UpdateName: "update", Args: []any{1}, WaitForStage: client.WorkflowUpdateStageCompleted, - }, startOp) + }, + StartOperation: startOp, + }) // NOTE that WorkflowExecutionErrorWhenAlreadyStarted (defaults to false) has no impact ts.ErrorContains(err, "Workflow execution is already running") @@ -4180,10 +4209,16 @@ func (ts *IntegrationTestSuite) TestUpdateWithStartWorkflow() { Args: []any{1}, WaitForStage: client.WorkflowUpdateStageCompleted, } - _, err := ts.client.UpdateWithStartWorkflow(ctx, updateOptions, startOp) + _, err := ts.client.UpdateWithStartWorkflow(ctx, client.UpdateWithStartWorkflowOptions{ + UpdateOptions: updateOptions, + StartOperation: startOp, + }) ts.NoError(err) - _, err = ts.client.UpdateWithStartWorkflow(ctx, updateOptions, startOp) + _, err = ts.client.UpdateWithStartWorkflow(ctx, client.UpdateWithStartWorkflowOptions{ + UpdateOptions: updateOptions, + StartOperation: startOp, + }) ts.ErrorContains(err, "invalid WithStartWorkflowOperation: was already executed") }) @@ -4196,12 +4231,14 @@ func (ts *IntegrationTestSuite) TestUpdateWithStartWorkflow() { ctx = context.WithValue(ctx, contextKey(testContextKey2), "propagatedValue2") ctx = context.WithValue(ctx, contextKey(testContextKey3), "non-propagatedValue") - _, err := ts.client.UpdateWithStartWorkflow(ctx, - client.UpdateWorkflowOptions{ + _, err := ts.client.UpdateWithStartWorkflow(ctx, client.UpdateWithStartWorkflowOptions{ + UpdateOptions: client.UpdateWorkflowOptions{ UpdateName: "update", Args: []any{1}, WaitForStage: client.WorkflowUpdateStageCompleted, - }, startOp) + }, + StartOperation: startOp, + }) ts.NoError(err) var propagatedValues []string