Skip to content

Commit

Permalink
remove runID, improve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vancexu committed Mar 22, 2018
1 parent 1be26bf commit be30b07
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 53 deletions.
4 changes: 2 additions & 2 deletions .gen/go/cadence/idl.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions .gen/go/shared/idl.go

Large diffs are not rendered by default.

28 changes: 20 additions & 8 deletions .gen/go/shared/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,16 @@ type (
// - InternalServiceError
SignalWorkflow(ctx context.Context, workflowID string, runID string, signalName string, arg interface{}) error

// SignalWithStartWorkflow sends a signals to a workflow in execution, if workflow is not running or not found,
// it starts workflow then sends the signal in transaction.
// - workflowID, runID, signalName, signalArg are same as SignalWorkflow's parameters
// - options, workflow, workflowArgs are same as StartWorkflow's parameters
// SignalWithStartWorkflow sends a signal to a running workflow.
// If the workflow is not running or not found, it starts the workflow and then sends the signal in transaction.
// - workflowID, signalName, signalArg are same as SignalWorkflow's parameters
// - workflow, workflowArgs are same as StartWorkflow's parameters
// - options.WorkflowIDReusePolicy will be ignored, and WorkflowIDReusePolicyAllowDuplicate will be used as the policy
// The errors it can return:
// - EntityNotExistsError, if domain does not exists
// - EntityNotExistsError, if domain does not exist
// - BadRequestError
// - InternalServiceError
SignalWithStartWorkflow(ctx context.Context, workflowID string, runID string, signalName string, signalArg interface{},
SignalWithStartWorkflow(ctx context.Context, workflowID string, signalName string, signalArg interface{},
options StartWorkflowOptions, workflow interface{}, workflowArgs ...interface{}) (*workflow.Execution, error)

// CancelWorkflow cancels a workflow in execution
Expand Down
8 changes: 4 additions & 4 deletions idl/github.com/uber/cadence/cadence.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ service WorkflowService {
)

/**
* SignalWithStartWorkflowExecution is used to ensure sending a signal event to a workflow execution.
* If workflow is running, this results in WorkflowExecutionSignaled event recorded in the history
* SignalWithStartWorkflowExecution is used to ensure sending signal to a workflow.
* If the workflow is running, this results in WorkflowExecutionSignaled event being recorded in the history
* and a decision task being created for the execution.
* If workflow is not running or not found, this results in WorkflowExecutionStarted and WorkflowExecutionSignaled
* event recorded in history, and a decision task being created for the execution
* If the workflow is not running or not found, this results in WorkflowExecutionStarted and WorkflowExecutionSignaled
* events being recorded in history, and a decision task being created for the execution
**/
shared.StartWorkflowExecutionResponse SignalWithStartWorkflowExecution(1: shared.SignalWithStartWorkflowExecutionRequest signalWithStartRequest)
throws (
Expand Down
2 changes: 1 addition & 1 deletion idl/github.com/uber/cadence/shared.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ struct SignalWorkflowExecutionRequest {

struct SignalWithStartWorkflowExecutionRequest {
10: optional string domain
20: optional WorkflowExecution workflowExecution
20: optional string workflowId
30: optional WorkflowType workflowType
40: optional TaskList taskList
50: optional binary input
Expand Down
13 changes: 7 additions & 6 deletions internal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,16 @@ type (
// - InternalServiceError
SignalWorkflow(ctx context.Context, workflowID string, runID string, signalName string, arg interface{}) error

// SignalWithStartWorkflow sends a signals to a workflow in execution, if workflow is not running or not found,
// it starts workflow then sends the signal in transaction.
// - workflowID, runID, signalName, signalArg are same as SignalWorkflow's parameters
// - options, workflow, workflowArgs are same as StartWorkflow's parameters
// SignalWithStartWorkflow sends a signal to a running workflow.
// If the workflow is not running or not found, it starts the workflow and then sends the signal in transaction.
// - workflowID, signalName, signalArg are same as SignalWorkflow's parameters
// - workflow, workflowArgs are same as StartWorkflow's parameters
// - options.WorkflowIDReusePolicy will be ignored, and WorkflowIDReusePolicyAllowDuplicate will be used as the policy
// The errors it can return:
// - EntityNotExistsError, if domain does not exists
// - EntityNotExistsError, if domain does not exist
// - BadRequestError
// - InternalServiceError
SignalWithStartWorkflow(ctx context.Context, workflowID string, runID string, signalName string, signalArg interface{},
SignalWithStartWorkflow(ctx context.Context, workflowID string, signalName string, signalArg interface{},
options StartWorkflowOptions, workflow interface{}, workflowArgs ...interface{}) (*WorkflowExecution, error)

// CancelWorkflow cancels a workflow in execution
Expand Down
22 changes: 9 additions & 13 deletions internal/internal_workflow_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ func (wc *workflowClient) SignalWorkflow(ctx context.Context, workflowID string,
}, serviceOperationRetryPolicy, isServiceTransientError)
}

// SignalWithStartWorkflow sends a signals to a workflow in execution, if workflow is not running or not found,
// it starts workflow then sends the signal in transaction
func (wc *workflowClient) SignalWithStartWorkflow(ctx context.Context, workflowID string, runID string, signalName string, signalArg interface{},
// SignalWithStartWorkflow sends a signal to a running workflow.
// If the workflow is not running or not found, it starts the workflow and then sends the signal in transaction.
func (wc *workflowClient) SignalWithStartWorkflow(ctx context.Context, workflowID string, signalName string, signalArg interface{},
options StartWorkflowOptions, workflowFunc interface{}, workflowArgs ...interface{}) (*WorkflowExecution, error) {

signalInput, err := getEncodedArg(signalArg)
Expand Down Expand Up @@ -300,17 +300,13 @@ func (wc *workflowClient) SignalWithStartWorkflow(ctx context.Context, workflowI
return nil, err
}

execution := &s.WorkflowExecution{
WorkflowId: common.StringPtr(workflowID),
RunId: getRunID(runID),
}
signalWithStartRequest := &s.SignalWithStartWorkflowExecutionRequest{
Domain: common.StringPtr(wc.domain),
RequestId: common.StringPtr(uuid.New()),
WorkflowExecution: execution,
WorkflowType: workflowTypePtr(*workflowType),
TaskList: common.TaskListPtr(s.TaskList{Name: common.StringPtr(options.TaskList)}),
Input: input,
Domain: common.StringPtr(wc.domain),
RequestId: common.StringPtr(uuid.New()),
WorkflowId: common.StringPtr(workflowID),
WorkflowType: workflowTypePtr(*workflowType),
TaskList: common.TaskListPtr(s.TaskList{Name: common.StringPtr(options.TaskList)}),
Input: input,
ExecutionStartToCloseTimeoutSeconds: common.Int32Ptr(executionTimeout),
TaskStartToCloseTimeoutSeconds: common.Int32Ptr(decisionTaskTimeout),
SignalName: common.StringPtr(signalName),
Expand Down
10 changes: 5 additions & 5 deletions internal/internal_workflow_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,12 +544,12 @@ func (s *workflowClientTestSuite) TestSignalWithStartWorkflow() {
}
s.service.EXPECT().SignalWithStartWorkflowExecution(gomock.Any(), gomock.Any(), gomock.Any()).Return(createResponse, nil).Times(2)

resp, err := s.client.SignalWithStartWorkflow(context.Background(), workflowID, runID, signalName, signalInput,
resp, err := s.client.SignalWithStartWorkflow(context.Background(), workflowID, signalName, signalInput,
options, workflowType)
s.Nil(err)
s.Equal(createResponse.GetRunId(), resp.RunID)

resp, err = s.client.SignalWithStartWorkflow(context.Background(), "", runID, signalName, signalInput,
resp, err = s.client.SignalWithStartWorkflow(context.Background(), "", signalName, signalInput,
options, workflowType)
s.Nil(err)
s.Equal(createResponse.GetRunId(), resp.RunID)
Expand All @@ -560,13 +560,13 @@ func (s *workflowClientTestSuite) TestSignalWithStartWorkflow_Error() {
signalInput := []byte("my signal input")
options := StartWorkflowOptions{}

resp, err := s.client.SignalWithStartWorkflow(context.Background(), workflowID, runID, signalName, signalInput,
resp, err := s.client.SignalWithStartWorkflow(context.Background(), workflowID, signalName, signalInput,
options, workflowType)
s.NotNil(err)
s.Nil(resp)

options.TaskList = tasklist
resp, err = s.client.SignalWithStartWorkflow(context.Background(), workflowID, runID, signalName, signalInput,
resp, err = s.client.SignalWithStartWorkflow(context.Background(), workflowID, signalName, signalInput,
options, workflowType)
s.NotNil(err)
s.Nil(resp)
Expand All @@ -576,7 +576,7 @@ func (s *workflowClientTestSuite) TestSignalWithStartWorkflow_Error() {
RunId: common.StringPtr(runID),
}
s.service.EXPECT().SignalWithStartWorkflowExecution(gomock.Any(), gomock.Any(), gomock.Any()).Return(createResponse, nil).Times(2)
resp, err = s.client.SignalWithStartWorkflow(context.Background(), workflowID, runID, signalName, signalInput,
resp, err = s.client.SignalWithStartWorkflow(context.Background(), workflowID, signalName, signalInput,
options, workflowType)
s.Nil(err)
s.Equal(createResponse.GetRunId(), resp.RunID)
Expand Down
12 changes: 6 additions & 6 deletions mocks/Client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit be30b07

Please sign in to comment.