From 68e7f3558a81693bbf1c14bd288b681aefdf44e5 Mon Sep 17 00:00:00 2001 From: Alex Shtin Date: Fri, 3 Apr 2020 17:44:41 -0700 Subject: [PATCH] Rearrange proto files (#85) --- client/client.go | 7 +- evictiontest/workflow_cache_eviction_test.go | 36 +- go.mod | 2 +- go.sum | 2 + internal/client.go | 24 +- internal/common/util/stringer.go | 66 +-- internal/context.go | 5 +- internal/error.go | 10 +- internal/error_test.go | 29 +- internal/headers.go | 10 +- internal/headers_test.go | 25 +- internal/internal_activity.go | 9 +- internal/internal_decision_state_machine.go | 118 ++--- .../internal_decision_state_machine_test.go | 80 +-- internal/internal_event_handlers.go | 171 +++---- internal/internal_event_handlers_test.go | 20 +- internal/internal_public.go | 4 +- internal/internal_task_handlers.go | 233 ++++----- .../internal_task_handlers_interfaces_test.go | 24 +- internal/internal_task_handlers_test.go | 474 +++++++++--------- internal/internal_task_pollers.go | 42 +- internal/internal_utils.go | 8 +- internal/internal_utils_test.go | 16 +- internal/internal_worker.go | 34 +- internal/internal_worker_base.go | 4 +- internal/internal_worker_interfaces_test.go | 7 +- internal/internal_worker_test.go | 110 ++-- internal/internal_workers_test.go | 90 ++-- internal/internal_workflow.go | 12 +- internal/internal_workflow_client.go | 77 +-- internal/internal_workflow_client_test.go | 142 +++--- internal/internal_workflow_testsuite.go | 22 +- internal/internal_workflow_testsuite_test.go | 34 +- internal/tracer_test.go | 11 +- internal/workflow.go | 17 +- internal/workflow_testsuite.go | 10 +- mocks/Client.go | 14 +- mocks/HistoryEventIterator.go | 10 +- mocks/mock_test.go | 8 +- test/integration_test.go | 15 +- test/workflow_test.go | 10 +- worker/worker.go | 4 +- workflow/error.go | 4 +- 43 files changed, 1046 insertions(+), 1004 deletions(-) diff --git a/client/client.go b/client/client.go index 223d76ff6..f8a330756 100644 --- a/client/client.go +++ b/client/client.go @@ -27,7 +27,8 @@ package client import ( "context" - "go.temporal.io/temporal-proto/enums" + filterpb "go.temporal.io/temporal-proto/filter" + tasklistpb "go.temporal.io/temporal-proto/tasklist" "go.temporal.io/temporal-proto/workflowservice" "go.temporal.io/temporal/encoded" @@ -189,7 +190,7 @@ type ( // } // events = append(events, event) // } - GetWorkflowHistory(ctx context.Context, workflowID string, runID string, isLongPoll bool, filterType enums.HistoryEventFilterType) HistoryEventIterator + GetWorkflowHistory(ctx context.Context, workflowID string, runID string, isLongPoll bool, filterType filterpb.HistoryEventFilterType) HistoryEventIterator // CompleteActivity reports activity completed. // activity Execute method can return activity.ErrResultPending to @@ -346,7 +347,7 @@ type ( // - BadRequestError // - InternalServiceError // - EntityNotExistError - DescribeTaskList(ctx context.Context, tasklist string, tasklistType enums.TaskListType) (*workflowservice.DescribeTaskListResponse, error) + DescribeTaskList(ctx context.Context, tasklist string, tasklistType tasklistpb.TaskListType) (*workflowservice.DescribeTaskListResponse, error) // CloseConnection closes underlying gRPC connection. CloseConnection() error diff --git a/evictiontest/workflow_cache_eviction_test.go b/evictiontest/workflow_cache_eviction_test.go index 64962119b..5234cd471 100644 --- a/evictiontest/workflow_cache_eviction_test.go +++ b/evictiontest/workflow_cache_eviction_test.go @@ -37,8 +37,10 @@ import ( "github.com/golang/mock/gomock" log "github.com/sirupsen/logrus" "github.com/stretchr/testify/suite" - commonproto "go.temporal.io/temporal-proto/common" - "go.temporal.io/temporal-proto/enums" + commonpb "go.temporal.io/temporal-proto/common" + eventpb "go.temporal.io/temporal-proto/event" + executionpb "go.temporal.io/temporal-proto/execution" + tasklistpb "go.temporal.io/temporal-proto/tasklist" "go.temporal.io/temporal-proto/workflowservice" "go.temporal.io/temporal-proto/workflowservicemock" "go.uber.org/atomic" @@ -87,26 +89,26 @@ func TestWorkersTestSuite(t *testing.T) { suite.Run(t, new(CacheEvictionSuite)) } -func createTestEventWorkflowExecutionStarted(eventID int64, attr *commonproto.WorkflowExecutionStartedEventAttributes) *commonproto.HistoryEvent { - return &commonproto.HistoryEvent{ +func createTestEventWorkflowExecutionStarted(eventID int64, attr *eventpb.WorkflowExecutionStartedEventAttributes) *eventpb.HistoryEvent { + return &eventpb.HistoryEvent{ EventId: eventID, - EventType: enums.EventTypeWorkflowExecutionStarted, - Attributes: &commonproto.HistoryEvent_WorkflowExecutionStartedEventAttributes{WorkflowExecutionStartedEventAttributes: attr}} + EventType: eventpb.EventTypeWorkflowExecutionStarted, + Attributes: &eventpb.HistoryEvent_WorkflowExecutionStartedEventAttributes{WorkflowExecutionStartedEventAttributes: attr}} } -func createTestEventDecisionTaskScheduled(eventID int64, attr *commonproto.DecisionTaskScheduledEventAttributes) *commonproto.HistoryEvent { - return &commonproto.HistoryEvent{ +func createTestEventDecisionTaskScheduled(eventID int64, attr *eventpb.DecisionTaskScheduledEventAttributes) *eventpb.HistoryEvent { + return &eventpb.HistoryEvent{ EventId: eventID, - EventType: enums.EventTypeDecisionTaskScheduled, - Attributes: &commonproto.HistoryEvent_DecisionTaskScheduledEventAttributes{DecisionTaskScheduledEventAttributes: attr}} + EventType: eventpb.EventTypeDecisionTaskScheduled, + Attributes: &eventpb.HistoryEvent_DecisionTaskScheduledEventAttributes{DecisionTaskScheduledEventAttributes: attr}} } func (s *CacheEvictionSuite) TestResetStickyOnEviction() { - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{ - TaskList: &commonproto.TaskList{Name: "tasklist"}, + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{ + TaskList: &tasklistpb.TaskList{Name: "tasklist"}, }), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{}), } var taskCounter atomic.Int32 // lambda variable to keep count @@ -122,9 +124,9 @@ func (s *CacheEvictionSuite) TestResetStickyOnEviction() { // after polling it or giving an error ret := &workflowservice.PollForDecisionTaskResponse{ TaskToken: make([]byte, 5), - WorkflowExecution: &commonproto.WorkflowExecution{WorkflowId: workflowID, RunId: runID}, - WorkflowType: &commonproto.WorkflowType{Name: "testReplayWorkflow"}, - History: &commonproto.History{Events: testEvents}, + WorkflowExecution: &executionpb.WorkflowExecution{WorkflowId: workflowID, RunId: runID}, + WorkflowType: &commonpb.WorkflowType{Name: "testReplayWorkflow"}, + History: &eventpb.History{Events: testEvents}, PreviousStartedEventId: 5} return ret, nil } diff --git a/go.mod b/go.mod index e66f0a4a1..882a969b1 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/uber-go/tally v3.3.15+incompatible github.com/uber/jaeger-client-go v2.22.1+incompatible github.com/uber/jaeger-lib v2.2.0+incompatible // indirect - go.temporal.io/temporal-proto v0.20.7 + go.temporal.io/temporal-proto v0.20.11 go.uber.org/atomic v1.6.0 go.uber.org/goleak v1.0.0 go.uber.org/zap v1.14.1 diff --git a/go.sum b/go.sum index 042bc448c..e8efc75b3 100644 --- a/go.sum +++ b/go.sum @@ -93,6 +93,8 @@ github.com/uber/jaeger-lib v2.2.0+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6 github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.temporal.io/temporal-proto v0.20.7 h1:lM+pnrSTHyzwI2Wdzg4XfurTHC9eqaKYZDDw420VCAU= go.temporal.io/temporal-proto v0.20.7/go.mod h1:Lv8L8YBpbp0Z7V5nbvw5UD0j7x0isebhCOIDLkBqn6s= +go.temporal.io/temporal-proto v0.20.11 h1:IvMUp7qsKZNMLfJwtGLVXiOEhiC8v6cHmKdvKyqq+s4= +go.temporal.io/temporal-proto v0.20.11/go.mod h1:Lv8L8YBpbp0Z7V5nbvw5UD0j7x0isebhCOIDLkBqn6s= go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/goleak v1.0.0 h1:qsup4IcBdlmsnGfqyLl4Ntn3C2XCCuKAE7DwHpScyUo= diff --git a/internal/client.go b/internal/client.go index 6ae062305..25c7afd02 100644 --- a/internal/client.go +++ b/internal/client.go @@ -28,7 +28,9 @@ import ( "github.com/opentracing/opentracing-go" "github.com/uber-go/tally" - "go.temporal.io/temporal-proto/enums" + commonpb "go.temporal.io/temporal-proto/common" + filterpb "go.temporal.io/temporal-proto/filter" + tasklistpb "go.temporal.io/temporal-proto/tasklist" "go.temporal.io/temporal-proto/workflowservice" "go.uber.org/zap" "google.golang.org/grpc" @@ -156,7 +158,7 @@ type ( // } // events = append(events, event) // } - GetWorkflowHistory(ctx context.Context, workflowID string, runID string, isLongPoll bool, filterType enums.HistoryEventFilterType) HistoryEventIterator + GetWorkflowHistory(ctx context.Context, workflowID string, runID string, isLongPoll bool, filterType filterpb.HistoryEventFilterType) HistoryEventIterator // CompleteActivity reports activity completed. // activity Execute method can return acitivity.activity.ErrResultPending to @@ -304,7 +306,7 @@ type ( // - BadRequestError // - InternalServiceError // - EntityNotExistError - DescribeTaskList(ctx context.Context, tasklist string, tasklistType enums.TaskListType) (*workflowservice.DescribeTaskListResponse, error) + DescribeTaskList(ctx context.Context, tasklist string, tasklistType tasklistpb.TaskListType) (*workflowservice.DescribeTaskListResponse, error) // CloseConnection closes underlying gRPC connection. CloseConnection() error @@ -644,27 +646,27 @@ func newNamespaceServiceClient(workflowServiceClient workflowservice.WorkflowSer } } -func (p WorkflowIDReusePolicy) toProto() enums.WorkflowIdReusePolicy { +func (p WorkflowIDReusePolicy) toProto() commonpb.WorkflowIdReusePolicy { switch p { case WorkflowIDReusePolicyAllowDuplicate: - return enums.WorkflowIdReusePolicyAllowDuplicate + return commonpb.WorkflowIdReusePolicyAllowDuplicate case WorkflowIDReusePolicyAllowDuplicateFailedOnly: - return enums.WorkflowIdReusePolicyAllowDuplicateFailedOnly + return commonpb.WorkflowIdReusePolicyAllowDuplicateFailedOnly case WorkflowIDReusePolicyRejectDuplicate: - return enums.WorkflowIdReusePolicyRejectDuplicate + return commonpb.WorkflowIdReusePolicyRejectDuplicate default: panic(fmt.Sprintf("unknown workflow reuse policy %v", p)) } } -func (p ParentClosePolicy) toProto() enums.ParentClosePolicy { +func (p ParentClosePolicy) toProto() commonpb.ParentClosePolicy { switch p { case ParentClosePolicyAbandon: - return enums.ParentClosePolicyAbandon + return commonpb.ParentClosePolicyAbandon case ParentClosePolicyRequestCancel: - return enums.ParentClosePolicyRequestCancel + return commonpb.ParentClosePolicyRequestCancel case ParentClosePolicyTerminate: - return enums.ParentClosePolicyTerminate + return commonpb.ParentClosePolicyTerminate default: panic(fmt.Sprintf("unknown workflow parent close policy %v", p)) } diff --git a/internal/common/util/stringer.go b/internal/common/util/stringer.go index be8b4b502..12ac3e7c4 100644 --- a/internal/common/util/stringer.go +++ b/internal/common/util/stringer.go @@ -25,8 +25,8 @@ import ( "fmt" "reflect" - commonproto "go.temporal.io/temporal-proto/common" - "go.temporal.io/temporal-proto/enums" + decisionpb "go.temporal.io/temporal-proto/decision" + eventpb "go.temporal.io/temporal-proto/event" ) func anyToString(d interface{}) string { @@ -78,73 +78,73 @@ func valueToString(v reflect.Value) string { } // HistoryEventToString convert HistoryEvent to string -func HistoryEventToString(e *commonproto.HistoryEvent) string { +func HistoryEventToString(e *eventpb.HistoryEvent) string { var data interface{} switch e.GetEventType() { - case enums.EventTypeWorkflowExecutionStarted: + case eventpb.EventTypeWorkflowExecutionStarted: data = e.GetWorkflowExecutionStartedEventAttributes() - case enums.EventTypeWorkflowExecutionCompleted: + case eventpb.EventTypeWorkflowExecutionCompleted: data = e.GetWorkflowExecutionCompletedEventAttributes() - case enums.EventTypeWorkflowExecutionFailed: + case eventpb.EventTypeWorkflowExecutionFailed: data = e.GetWorkflowExecutionFailedEventAttributes() - case enums.EventTypeWorkflowExecutionTimedOut: + case eventpb.EventTypeWorkflowExecutionTimedOut: data = e.GetWorkflowExecutionTimedOutEventAttributes() - case enums.EventTypeDecisionTaskScheduled: + case eventpb.EventTypeDecisionTaskScheduled: data = e.GetDecisionTaskScheduledEventAttributes() - case enums.EventTypeDecisionTaskStarted: + case eventpb.EventTypeDecisionTaskStarted: data = e.GetDecisionTaskStartedEventAttributes() - case enums.EventTypeDecisionTaskCompleted: + case eventpb.EventTypeDecisionTaskCompleted: data = e.GetDecisionTaskCompletedEventAttributes() - case enums.EventTypeDecisionTaskTimedOut: + case eventpb.EventTypeDecisionTaskTimedOut: data = e.GetDecisionTaskTimedOutEventAttributes() - case enums.EventTypeActivityTaskScheduled: + case eventpb.EventTypeActivityTaskScheduled: data = e.GetActivityTaskScheduledEventAttributes() - case enums.EventTypeActivityTaskStarted: + case eventpb.EventTypeActivityTaskStarted: data = e.GetActivityTaskStartedEventAttributes() - case enums.EventTypeActivityTaskCompleted: + case eventpb.EventTypeActivityTaskCompleted: data = e.GetActivityTaskCompletedEventAttributes() - case enums.EventTypeActivityTaskFailed: + case eventpb.EventTypeActivityTaskFailed: data = e.GetActivityTaskFailedEventAttributes() - case enums.EventTypeActivityTaskTimedOut: + case eventpb.EventTypeActivityTaskTimedOut: data = e.GetActivityTaskTimedOutEventAttributes() - case enums.EventTypeActivityTaskCancelRequested: + case eventpb.EventTypeActivityTaskCancelRequested: data = e.GetActivityTaskCancelRequestedEventAttributes() - case enums.EventTypeRequestCancelActivityTaskFailed: + case eventpb.EventTypeRequestCancelActivityTaskFailed: data = e.GetRequestCancelActivityTaskFailedEventAttributes() - case enums.EventTypeActivityTaskCanceled: + case eventpb.EventTypeActivityTaskCanceled: data = e.GetActivityTaskCanceledEventAttributes() - case enums.EventTypeTimerStarted: + case eventpb.EventTypeTimerStarted: data = e.GetTimerStartedEventAttributes() - case enums.EventTypeTimerFired: + case eventpb.EventTypeTimerFired: data = e.GetTimerFiredEventAttributes() - case enums.EventTypeCancelTimerFailed: + case eventpb.EventTypeCancelTimerFailed: data = e.GetCancelTimerFailedEventAttributes() - case enums.EventTypeTimerCanceled: + case eventpb.EventTypeTimerCanceled: data = e.GetTimerCanceledEventAttributes() - case enums.EventTypeMarkerRecorded: + case eventpb.EventTypeMarkerRecorded: data = e.GetMarkerRecordedEventAttributes() - case enums.EventTypeWorkflowExecutionTerminated: + case eventpb.EventTypeWorkflowExecutionTerminated: data = e.GetWorkflowExecutionTerminatedEventAttributes() default: @@ -155,28 +155,28 @@ func HistoryEventToString(e *commonproto.HistoryEvent) string { } // DecisionToString convert Decision to string -func DecisionToString(d *commonproto.Decision) string { +func DecisionToString(d *decisionpb.Decision) string { var data interface{} switch d.GetDecisionType() { - case enums.DecisionTypeScheduleActivityTask: + case decisionpb.DecisionTypeScheduleActivityTask: data = d.GetScheduleActivityTaskDecisionAttributes() - case enums.DecisionTypeRequestCancelActivityTask: + case decisionpb.DecisionTypeRequestCancelActivityTask: data = d.GetRequestCancelActivityTaskDecisionAttributes() - case enums.DecisionTypeStartTimer: + case decisionpb.DecisionTypeStartTimer: data = d.GetStartTimerDecisionAttributes() - case enums.DecisionTypeCancelTimer: + case decisionpb.DecisionTypeCancelTimer: data = d.GetCancelTimerDecisionAttributes() - case enums.DecisionTypeCompleteWorkflowExecution: + case decisionpb.DecisionTypeCompleteWorkflowExecution: data = d.GetCompleteWorkflowExecutionDecisionAttributes() - case enums.DecisionTypeFailWorkflowExecution: + case decisionpb.DecisionTypeFailWorkflowExecution: data = d.GetFailWorkflowExecutionDecisionAttributes() - case enums.DecisionTypeRecordMarker: + case decisionpb.DecisionTypeRecordMarker: data = d.GetRecordMarkerDecisionAttributes() default: diff --git a/internal/context.go b/internal/context.go index 720c967e2..38a751409 100644 --- a/internal/context.go +++ b/internal/context.go @@ -25,8 +25,7 @@ import ( "time" "github.com/opentracing/opentracing-go" - - "go.temporal.io/temporal-proto/enums" + eventpb "go.temporal.io/temporal-proto/event" ) const activeSpanContextKey contextKey = "activeSpanContextKey" @@ -176,7 +175,7 @@ var ErrCanceled = NewCanceledError() // ErrDeadlineExceeded is the error returned by Context.Err when the context's // deadline passes. -var ErrDeadlineExceeded = NewTimeoutError(enums.TimeoutTypeScheduleToClose) +var ErrDeadlineExceeded = NewTimeoutError(eventpb.TimeoutTypeScheduleToClose) // A CancelFunc tells an operation to abandon its work. // A CancelFunc does not wait for the work to stop. diff --git a/internal/error.go b/internal/error.go index 434042eeb..31b85f27d 100644 --- a/internal/error.go +++ b/internal/error.go @@ -25,7 +25,7 @@ import ( "fmt" "strings" - "go.temporal.io/temporal-proto/enums" + eventpb "go.temporal.io/temporal-proto/event" ) /* @@ -97,7 +97,7 @@ type ( // TimeoutError returned when activity or child workflow timed out. TimeoutError struct { - timeoutType enums.TimeoutType + timeoutType eventpb.TimeoutType details Values } @@ -171,7 +171,7 @@ func NewCustomError(reason string, details ...interface{}) *CustomError { // NewTimeoutError creates TimeoutError instance. // Use NewHeartbeatTimeoutError to create heartbeat TimeoutError -func NewTimeoutError(timeoutType enums.TimeoutType, details ...interface{}) *TimeoutError { +func NewTimeoutError(timeoutType eventpb.TimeoutType, details ...interface{}) *TimeoutError { if len(details) == 1 { if d, ok := details[0].(*EncodedValues); ok { return &TimeoutError{timeoutType: timeoutType, details: d} @@ -182,7 +182,7 @@ func NewTimeoutError(timeoutType enums.TimeoutType, details ...interface{}) *Tim // NewHeartbeatTimeoutError creates TimeoutError instance func NewHeartbeatTimeoutError(details ...interface{}) *TimeoutError { - return NewTimeoutError(enums.TimeoutTypeHeartbeat, details...) + return NewTimeoutError(eventpb.TimeoutTypeHeartbeat, details...) } // NewCanceledError creates CanceledError instance @@ -277,7 +277,7 @@ func (e *TimeoutError) Error() string { } // TimeoutType return timeout type of this error -func (e *TimeoutError) TimeoutType() enums.TimeoutType { +func (e *TimeoutError) TimeoutType() eventpb.TimeoutType { return e.timeoutType } diff --git a/internal/error_test.go b/internal/error_test.go index ce73757a4..8b924c158 100644 --- a/internal/error_test.go +++ b/internal/error_test.go @@ -26,10 +26,11 @@ import ( "testing" "github.com/stretchr/testify/require" - "go.uber.org/zap" - commonproto "go.temporal.io/temporal-proto/common" - "go.temporal.io/temporal-proto/enums" + commonpb "go.temporal.io/temporal-proto/common" + decisionpb "go.temporal.io/temporal-proto/decision" + eventpb "go.temporal.io/temporal-proto/event" + "go.uber.org/zap" ) const ( @@ -92,7 +93,7 @@ func Test_ActivityNotRegistered(t *testing.T) { } func Test_TimeoutError(t *testing.T) { - timeoutErr := NewTimeoutError(enums.TimeoutTypeScheduleToStart) + timeoutErr := NewTimeoutError(eventpb.TimeoutTypeScheduleToStart) require.False(t, timeoutErr.HasDetails()) var data string require.Equal(t, ErrNoData, timeoutErr.Details(&data)) @@ -104,12 +105,12 @@ func Test_TimeoutError(t *testing.T) { } func Test_TimeoutError_WithDetails(t *testing.T) { - testTimeoutErrorDetails(t, enums.TimeoutTypeHeartbeat) - testTimeoutErrorDetails(t, enums.TimeoutTypeScheduleToClose) - testTimeoutErrorDetails(t, enums.TimeoutTypeStartToClose) + testTimeoutErrorDetails(t, eventpb.TimeoutTypeHeartbeat) + testTimeoutErrorDetails(t, eventpb.TimeoutTypeScheduleToClose) + testTimeoutErrorDetails(t, eventpb.TimeoutTypeStartToClose) } -func testTimeoutErrorDetails(t *testing.T, timeoutType enums.TimeoutType) { +func testTimeoutErrorDetails(t *testing.T, timeoutType eventpb.TimeoutType) { context := &workflowEnvironmentImpl{ decisionsHelper: newDecisionsHelper(), dataConverter: getDefaultDataConverter(), @@ -119,7 +120,7 @@ func testTimeoutErrorDetails(t *testing.T, timeoutType enums.TimeoutType) { activityID := "activityID" context.decisionsHelper.scheduledEventIDToActivityID[5] = activityID di := h.newActivityDecisionStateMachine( - &commonproto.ScheduleActivityTaskDecisionAttributes{ActivityId: activityID}) + &decisionpb.ScheduleActivityTaskDecisionAttributes{ActivityId: activityID}) di.state = decisionStateInitiated di.setData(&scheduledActivity{ callback: func(r []byte, e error) { @@ -128,7 +129,7 @@ func testTimeoutErrorDetails(t *testing.T, timeoutType enums.TimeoutType) { }) context.decisionsHelper.addDecision(di) encodedDetails1, _ := context.dataConverter.ToData(testErrorDetails1) - event := createTestEventActivityTaskTimedOut(7, &commonproto.ActivityTaskTimedOutEventAttributes{ + event := createTestEventActivityTaskTimedOut(7, &eventpb.ActivityTaskTimedOutEventAttributes{ Details: encodedDetails1, ScheduledEventId: 5, StartedEventId: 6, @@ -403,7 +404,7 @@ func Test_SignalExternalWorkflowExecutionFailedError(t *testing.T) { signalID := "signalID" context.decisionsHelper.scheduledEventIDToSignalID[initiatedEventID] = signalID di := h.newSignalExternalWorkflowStateMachine( - &commonproto.SignalExternalWorkflowExecutionDecisionAttributes{}, + &decisionpb.SignalExternalWorkflowExecutionDecisionAttributes{}, signalID, ) di.state = decisionStateInitiated @@ -414,9 +415,9 @@ func Test_SignalExternalWorkflowExecutionFailedError(t *testing.T) { }) context.decisionsHelper.addDecision(di) weh := &workflowExecutionEventHandlerImpl{context, nil} - event := createTestEventSignalExternalWorkflowExecutionFailed(1, &commonproto.SignalExternalWorkflowExecutionFailedEventAttributes{ + event := createTestEventSignalExternalWorkflowExecutionFailed(1, &eventpb.SignalExternalWorkflowExecutionFailedEventAttributes{ InitiatedEventId: initiatedEventID, - Cause: enums.SignalExternalWorkflowExecutionFailedCauseUnknownExternalWorkflowExecution, + Cause: eventpb.SignalExternalWorkflowExecutionFailedCauseUnknownExternalWorkflowExecution, }) require.NoError(t, weh.handleSignalExternalWorkflowExecutionFailed(event)) _, ok := actualErr.(*UnknownExternalWorkflowExecutionError) @@ -432,7 +433,7 @@ func Test_ContinueAsNewError(t *testing.T) { return NewContinueAsNewError(ctx, continueAsNewWfName, a1, a2) } - header := &commonproto.Header{ + header := &commonpb.Header{ Fields: map[string][]byte{"test": []byte("test-data")}, } diff --git a/internal/headers.go b/internal/headers.go index 6accd0565..4d9b24900 100644 --- a/internal/headers.go +++ b/internal/headers.go @@ -23,7 +23,7 @@ package internal import ( "context" - commonproto "go.temporal.io/temporal-proto/common" + commonpb "go.temporal.io/temporal-proto/common" ) // HeaderWriter is an interface to write information to temporal headers @@ -55,7 +55,7 @@ type ContextPropagator interface { } type headerReader struct { - header *commonproto.Header + header *commonpb.Header } func (hr *headerReader) ForEachKey(handler func(string, []byte) error) error { @@ -71,12 +71,12 @@ func (hr *headerReader) ForEachKey(handler func(string, []byte) error) error { } // NewHeaderReader returns a header reader interface -func NewHeaderReader(header *commonproto.Header) HeaderReader { +func NewHeaderReader(header *commonpb.Header) HeaderReader { return &headerReader{header} } type headerWriter struct { - header *commonproto.Header + header *commonpb.Header } func (hw *headerWriter) Set(key string, value []byte) { @@ -87,7 +87,7 @@ func (hw *headerWriter) Set(key string, value []byte) { } // NewHeaderWriter returns a header writer interface -func NewHeaderWriter(header *commonproto.Header) HeaderWriter { +func NewHeaderWriter(header *commonpb.Header) HeaderWriter { if header != nil && header.Fields == nil { header.Fields = make(map[string][]byte) } diff --git a/internal/headers_test.go b/internal/headers_test.go index 893028a2f..7219ab521 100644 --- a/internal/headers_test.go +++ b/internal/headers_test.go @@ -24,34 +24,33 @@ import ( "testing" "github.com/stretchr/testify/assert" - - commonproto "go.temporal.io/temporal-proto/common" + commonpb "go.temporal.io/temporal-proto/common" ) func TestHeaderWriter(t *testing.T) { t.Parallel() tests := []struct { name string - initial *commonproto.Header - expected *commonproto.Header + initial *commonpb.Header + expected *commonpb.Header vals map[string][]byte }{ { "no values", - &commonproto.Header{ + &commonpb.Header{ Fields: map[string][]byte{}, }, - &commonproto.Header{ + &commonpb.Header{ Fields: map[string][]byte{}, }, map[string][]byte{}, }, { "add values", - &commonproto.Header{ + &commonpb.Header{ Fields: map[string][]byte{}, }, - &commonproto.Header{ + &commonpb.Header{ Fields: map[string][]byte{ "key1": []byte("val1"), "key2": []byte("val2"), @@ -64,12 +63,12 @@ func TestHeaderWriter(t *testing.T) { }, { "overwrite values", - &commonproto.Header{ + &commonpb.Header{ Fields: map[string][]byte{ "key1": []byte("unexpected"), }, }, - &commonproto.Header{ + &commonpb.Header{ Fields: map[string][]byte{ "key1": []byte("val1"), "key2": []byte("val2"), @@ -99,13 +98,13 @@ func TestHeaderReader(t *testing.T) { t.Parallel() tests := []struct { name string - header *commonproto.Header + header *commonpb.Header keys map[string]struct{} isError bool }{ { "valid values", - &commonproto.Header{ + &commonpb.Header{ Fields: map[string][]byte{ "key1": []byte("val1"), "key2": []byte("val2"), @@ -116,7 +115,7 @@ func TestHeaderReader(t *testing.T) { }, { "invalid values", - &commonproto.Header{ + &commonpb.Header{ Fields: map[string][]byte{ "key1": []byte("val1"), "key2": []byte("val2"), diff --git a/internal/internal_activity.go b/internal/internal_activity.go index 19fc2921e..d3bf2b5f6 100644 --- a/internal/internal_activity.go +++ b/internal/internal_activity.go @@ -31,9 +31,8 @@ import ( "github.com/opentracing/opentracing-go" "github.com/uber-go/tally" + commonpb "go.temporal.io/temporal-proto/common" "go.uber.org/zap" - - commonproto "go.temporal.io/temporal-proto/common" ) type ( @@ -62,7 +61,7 @@ type ( HeartbeatTimeoutSeconds int32 WaitForCancellation bool OriginalTaskListName string - RetryPolicy *commonproto.RetryPolicy + RetryPolicy *commonpb.RetryPolicy } localActivityOptions struct { @@ -75,7 +74,7 @@ type ( ActivityType ActivityType Input []byte DataConverter DataConverter - Header *commonproto.Header + Header *commonpb.Header } executeLocalActivityParams struct { @@ -212,7 +211,7 @@ func getValidatedLocalActivityOptions(ctx Context) (*localActivityOptions, error return p, nil } -func validateRetryPolicy(p *commonproto.RetryPolicy) error { +func validateRetryPolicy(p *commonpb.RetryPolicy) error { if p == nil { return nil } diff --git a/internal/internal_decision_state_machine.go b/internal/internal_decision_state_machine.go index b10d8614f..f4f76ba18 100644 --- a/internal/internal_decision_state_machine.go +++ b/internal/internal_decision_state_machine.go @@ -24,8 +24,10 @@ import ( "container/list" "fmt" - commonproto "go.temporal.io/temporal-proto/common" - "go.temporal.io/temporal-proto/enums" + commonpb "go.temporal.io/temporal-proto/common" + decisionpb "go.temporal.io/temporal-proto/decision" + eventpb "go.temporal.io/temporal-proto/event" + executionpb "go.temporal.io/temporal-proto/execution" "go.temporal.io/temporal/internal/common/util" ) @@ -43,7 +45,7 @@ type ( getState() decisionState getID() decisionID isDone() bool - getDecision() *commonproto.Decision // return nil if there is no decision in current state + getDecision() *decisionpb.Decision // return nil if there is no decision in current state cancel() handleStartedEvent() @@ -70,23 +72,23 @@ type ( activityDecisionStateMachine struct { *decisionStateMachineBase - attributes *commonproto.ScheduleActivityTaskDecisionAttributes + attributes *decisionpb.ScheduleActivityTaskDecisionAttributes } timerDecisionStateMachine struct { *decisionStateMachineBase - attributes *commonproto.StartTimerDecisionAttributes + attributes *decisionpb.StartTimerDecisionAttributes canceled bool } childWorkflowDecisionStateMachine struct { *decisionStateMachineBase - attributes *commonproto.StartChildWorkflowExecutionDecisionAttributes + attributes *decisionpb.StartChildWorkflowExecutionDecisionAttributes } naiveDecisionStateMachine struct { *decisionStateMachineBase - decision *commonproto.Decision + decision *decisionpb.Decision } // only possible state transition is: CREATED->SENT->INITIATED->COMPLETED @@ -227,7 +229,7 @@ func (h *decisionsHelper) newDecisionStateMachineBase(decisionType decisionType, } } -func (h *decisionsHelper) newActivityDecisionStateMachine(attributes *commonproto.ScheduleActivityTaskDecisionAttributes) *activityDecisionStateMachine { +func (h *decisionsHelper) newActivityDecisionStateMachine(attributes *decisionpb.ScheduleActivityTaskDecisionAttributes) *activityDecisionStateMachine { base := h.newDecisionStateMachineBase(decisionTypeActivity, attributes.GetActivityId()) return &activityDecisionStateMachine{ decisionStateMachineBase: base, @@ -235,7 +237,7 @@ func (h *decisionsHelper) newActivityDecisionStateMachine(attributes *commonprot } } -func (h *decisionsHelper) newTimerDecisionStateMachine(attributes *commonproto.StartTimerDecisionAttributes) *timerDecisionStateMachine { +func (h *decisionsHelper) newTimerDecisionStateMachine(attributes *decisionpb.StartTimerDecisionAttributes) *timerDecisionStateMachine { base := h.newDecisionStateMachineBase(decisionTypeTimer, attributes.GetTimerId()) return &timerDecisionStateMachine{ decisionStateMachineBase: base, @@ -243,7 +245,7 @@ func (h *decisionsHelper) newTimerDecisionStateMachine(attributes *commonproto.S } } -func (h *decisionsHelper) newChildWorkflowDecisionStateMachine(attributes *commonproto.StartChildWorkflowExecutionDecisionAttributes) *childWorkflowDecisionStateMachine { +func (h *decisionsHelper) newChildWorkflowDecisionStateMachine(attributes *decisionpb.StartChildWorkflowExecutionDecisionAttributes) *childWorkflowDecisionStateMachine { base := h.newDecisionStateMachineBase(decisionTypeChildWorkflow, attributes.GetWorkflowId()) return &childWorkflowDecisionStateMachine{ decisionStateMachineBase: base, @@ -251,7 +253,7 @@ func (h *decisionsHelper) newChildWorkflowDecisionStateMachine(attributes *commo } } -func (h *decisionsHelper) newNaiveDecisionStateMachine(decisionType decisionType, id string, decision *commonproto.Decision) *naiveDecisionStateMachine { +func (h *decisionsHelper) newNaiveDecisionStateMachine(decisionType decisionType, id string, decision *decisionpb.Decision) *naiveDecisionStateMachine { base := h.newDecisionStateMachineBase(decisionType, id) return &naiveDecisionStateMachine{ decisionStateMachineBase: base, @@ -259,33 +261,33 @@ func (h *decisionsHelper) newNaiveDecisionStateMachine(decisionType decisionType } } -func (h *decisionsHelper) newMarkerDecisionStateMachine(id string, attributes *commonproto.RecordMarkerDecisionAttributes) *markerDecisionStateMachine { - d := createNewDecision(enums.DecisionTypeRecordMarker) - d.Attributes = &commonproto.Decision_RecordMarkerDecisionAttributes{RecordMarkerDecisionAttributes: attributes} +func (h *decisionsHelper) newMarkerDecisionStateMachine(id string, attributes *decisionpb.RecordMarkerDecisionAttributes) *markerDecisionStateMachine { + d := createNewDecision(decisionpb.DecisionTypeRecordMarker) + d.Attributes = &decisionpb.Decision_RecordMarkerDecisionAttributes{RecordMarkerDecisionAttributes: attributes} return &markerDecisionStateMachine{ naiveDecisionStateMachine: h.newNaiveDecisionStateMachine(decisionTypeMarker, id, d), } } -func (h *decisionsHelper) newCancelExternalWorkflowStateMachine(attributes *commonproto.RequestCancelExternalWorkflowExecutionDecisionAttributes, cancellationID string) *cancelExternalWorkflowDecisionStateMachine { - d := createNewDecision(enums.DecisionTypeRequestCancelExternalWorkflowExecution) - d.Attributes = &commonproto.Decision_RequestCancelExternalWorkflowExecutionDecisionAttributes{RequestCancelExternalWorkflowExecutionDecisionAttributes: attributes} +func (h *decisionsHelper) newCancelExternalWorkflowStateMachine(attributes *decisionpb.RequestCancelExternalWorkflowExecutionDecisionAttributes, cancellationID string) *cancelExternalWorkflowDecisionStateMachine { + d := createNewDecision(decisionpb.DecisionTypeRequestCancelExternalWorkflowExecution) + d.Attributes = &decisionpb.Decision_RequestCancelExternalWorkflowExecutionDecisionAttributes{RequestCancelExternalWorkflowExecutionDecisionAttributes: attributes} return &cancelExternalWorkflowDecisionStateMachine{ naiveDecisionStateMachine: h.newNaiveDecisionStateMachine(decisionTypeCancellation, cancellationID, d), } } -func (h *decisionsHelper) newSignalExternalWorkflowStateMachine(attributes *commonproto.SignalExternalWorkflowExecutionDecisionAttributes, signalID string) *signalExternalWorkflowDecisionStateMachine { - d := createNewDecision(enums.DecisionTypeSignalExternalWorkflowExecution) - d.Attributes = &commonproto.Decision_SignalExternalWorkflowExecutionDecisionAttributes{SignalExternalWorkflowExecutionDecisionAttributes: attributes} +func (h *decisionsHelper) newSignalExternalWorkflowStateMachine(attributes *decisionpb.SignalExternalWorkflowExecutionDecisionAttributes, signalID string) *signalExternalWorkflowDecisionStateMachine { + d := createNewDecision(decisionpb.DecisionTypeSignalExternalWorkflowExecution) + d.Attributes = &decisionpb.Decision_SignalExternalWorkflowExecutionDecisionAttributes{SignalExternalWorkflowExecutionDecisionAttributes: attributes} return &signalExternalWorkflowDecisionStateMachine{ naiveDecisionStateMachine: h.newNaiveDecisionStateMachine(decisionTypeSignal, signalID, d), } } -func (h *decisionsHelper) newUpsertSearchAttributesStateMachine(attributes *commonproto.UpsertWorkflowSearchAttributesDecisionAttributes, upsertID string) *upsertSearchAttributesDecisionStateMachine { - d := createNewDecision(enums.DecisionTypeUpsertWorkflowSearchAttributes) - d.Attributes = &commonproto.Decision_UpsertWorkflowSearchAttributesDecisionAttributes{UpsertWorkflowSearchAttributesDecisionAttributes: attributes} +func (h *decisionsHelper) newUpsertSearchAttributesStateMachine(attributes *decisionpb.UpsertWorkflowSearchAttributesDecisionAttributes, upsertID string) *upsertSearchAttributesDecisionStateMachine { + d := createNewDecision(decisionpb.DecisionTypeUpsertWorkflowSearchAttributes) + d.Attributes = &decisionpb.Decision_UpsertWorkflowSearchAttributesDecisionAttributes{UpsertWorkflowSearchAttributesDecisionAttributes: attributes} return &upsertSearchAttributesDecisionStateMachine{ naiveDecisionStateMachine: h.newNaiveDecisionStateMachine(decisionTypeUpsertSearchAttributes, upsertID, d), } @@ -427,15 +429,15 @@ func (d *decisionStateMachineBase) String() string { d.id, d.state, d.isDone(), d.history) } -func (d *activityDecisionStateMachine) getDecision() *commonproto.Decision { +func (d *activityDecisionStateMachine) getDecision() *decisionpb.Decision { switch d.state { case decisionStateCreated: - decision := createNewDecision(enums.DecisionTypeScheduleActivityTask) - decision.Attributes = &commonproto.Decision_ScheduleActivityTaskDecisionAttributes{ScheduleActivityTaskDecisionAttributes: d.attributes} + decision := createNewDecision(decisionpb.DecisionTypeScheduleActivityTask) + decision.Attributes = &decisionpb.Decision_ScheduleActivityTaskDecisionAttributes{ScheduleActivityTaskDecisionAttributes: d.attributes} return decision case decisionStateCanceledAfterInitiated: - decision := createNewDecision(enums.DecisionTypeRequestCancelActivityTask) - decision.Attributes = &commonproto.Decision_RequestCancelActivityTaskDecisionAttributes{RequestCancelActivityTaskDecisionAttributes: &commonproto.RequestCancelActivityTaskDecisionAttributes{ + decision := createNewDecision(decisionpb.DecisionTypeRequestCancelActivityTask) + decision.Attributes = &decisionpb.Decision_RequestCancelActivityTaskDecisionAttributes{RequestCancelActivityTaskDecisionAttributes: &decisionpb.RequestCancelActivityTaskDecisionAttributes{ ActivityId: d.attributes.ActivityId, }} return decision @@ -489,15 +491,15 @@ func (d *timerDecisionStateMachine) handleCancelFailedEvent() { } } -func (d *timerDecisionStateMachine) getDecision() *commonproto.Decision { +func (d *timerDecisionStateMachine) getDecision() *decisionpb.Decision { switch d.state { case decisionStateCreated: - decision := createNewDecision(enums.DecisionTypeStartTimer) - decision.Attributes = &commonproto.Decision_StartTimerDecisionAttributes{StartTimerDecisionAttributes: d.attributes} + decision := createNewDecision(decisionpb.DecisionTypeStartTimer) + decision.Attributes = &decisionpb.Decision_StartTimerDecisionAttributes{StartTimerDecisionAttributes: d.attributes} return decision case decisionStateCanceledAfterInitiated: - decision := createNewDecision(enums.DecisionTypeCancelTimer) - decision.Attributes = &commonproto.Decision_CancelTimerDecisionAttributes{CancelTimerDecisionAttributes: &commonproto.CancelTimerDecisionAttributes{ + decision := createNewDecision(decisionpb.DecisionTypeCancelTimer) + decision.Attributes = &decisionpb.Decision_CancelTimerDecisionAttributes{CancelTimerDecisionAttributes: &decisionpb.CancelTimerDecisionAttributes{ TimerId: d.attributes.TimerId, }} return decision @@ -506,15 +508,15 @@ func (d *timerDecisionStateMachine) getDecision() *commonproto.Decision { } } -func (d *childWorkflowDecisionStateMachine) getDecision() *commonproto.Decision { +func (d *childWorkflowDecisionStateMachine) getDecision() *decisionpb.Decision { switch d.state { case decisionStateCreated: - decision := createNewDecision(enums.DecisionTypeStartChildWorkflowExecution) - decision.Attributes = &commonproto.Decision_StartChildWorkflowExecutionDecisionAttributes{StartChildWorkflowExecutionDecisionAttributes: d.attributes} + decision := createNewDecision(decisionpb.DecisionTypeStartChildWorkflowExecution) + decision.Attributes = &decisionpb.Decision_StartChildWorkflowExecutionDecisionAttributes{StartChildWorkflowExecutionDecisionAttributes: d.attributes} return decision case decisionStateCanceledAfterStarted: - decision := createNewDecision(enums.DecisionTypeRequestCancelExternalWorkflowExecution) - decision.Attributes = &commonproto.Decision_RequestCancelExternalWorkflowExecutionDecisionAttributes{RequestCancelExternalWorkflowExecutionDecisionAttributes: &commonproto.RequestCancelExternalWorkflowExecutionDecisionAttributes{ + decision := createNewDecision(decisionpb.DecisionTypeRequestCancelExternalWorkflowExecution) + decision.Attributes = &decisionpb.Decision_RequestCancelExternalWorkflowExecutionDecisionAttributes{RequestCancelExternalWorkflowExecutionDecisionAttributes: &decisionpb.RequestCancelExternalWorkflowExecutionDecisionAttributes{ Namespace: d.attributes.Namespace, WorkflowId: d.attributes.WorkflowId, ChildWorkflowOnly: true, @@ -581,7 +583,7 @@ func (d *childWorkflowDecisionStateMachine) handleCompletionEvent() { } } -func (d *naiveDecisionStateMachine) getDecision() *commonproto.Decision { +func (d *naiveDecisionStateMachine) getDecision() *decisionpb.Decision { switch d.state { case decisionStateCreated: return d.decision @@ -711,7 +713,7 @@ func (h *decisionsHelper) addDecision(decision decisionStateMachine) { h.decisions[decision.getID()] = element } -func (h *decisionsHelper) scheduleActivityTask(attributes *commonproto.ScheduleActivityTaskDecisionAttributes) decisionStateMachine { +func (h *decisionsHelper) scheduleActivityTask(attributes *decisionpb.ScheduleActivityTaskDecisionAttributes) decisionStateMachine { decision := h.newActivityDecisionStateMachine(attributes) h.addDecision(decision) return decision @@ -752,16 +754,16 @@ func (h *decisionsHelper) handleRequestCancelActivityTaskFailed(activityID strin decision.handleCancelFailedEvent() } -func (h *decisionsHelper) getActivityID(event *commonproto.HistoryEvent) string { +func (h *decisionsHelper) getActivityID(event *eventpb.HistoryEvent) string { var scheduledEventID int64 = -1 switch event.GetEventType() { - case enums.EventTypeActivityTaskCanceled: + case eventpb.EventTypeActivityTaskCanceled: scheduledEventID = event.GetActivityTaskCanceledEventAttributes().GetScheduledEventId() - case enums.EventTypeActivityTaskCompleted: + case eventpb.EventTypeActivityTaskCompleted: scheduledEventID = event.GetActivityTaskCompletedEventAttributes().GetScheduledEventId() - case enums.EventTypeActivityTaskFailed: + case eventpb.EventTypeActivityTaskFailed: scheduledEventID = event.GetActivityTaskFailedEventAttributes().GetScheduledEventId() - case enums.EventTypeActivityTaskTimedOut: + case eventpb.EventTypeActivityTaskTimedOut: scheduledEventID = event.GetActivityTaskTimedOutEventAttributes().GetScheduledEventId() default: panicIllegalState(fmt.Sprintf("unexpected event type %v", event.GetEventType())) @@ -781,7 +783,7 @@ func (h *decisionsHelper) recordVersionMarker(changeID string, version Version, panic(err) } - recordMarker := &commonproto.RecordMarkerDecisionAttributes{ + recordMarker := &decisionpb.RecordMarkerDecisionAttributes{ MarkerName: versionMarkerName, Details: details, // Keep } @@ -793,7 +795,7 @@ func (h *decisionsHelper) recordVersionMarker(changeID string, version Version, func (h *decisionsHelper) recordSideEffectMarker(sideEffectID int32, data []byte) decisionStateMachine { markerID := fmt.Sprintf("%v_%v", sideEffectMarkerName, sideEffectID) - attributes := &commonproto.RecordMarkerDecisionAttributes{ + attributes := &decisionpb.RecordMarkerDecisionAttributes{ MarkerName: sideEffectMarkerName, Details: data, } @@ -804,7 +806,7 @@ func (h *decisionsHelper) recordSideEffectMarker(sideEffectID int32, data []byte func (h *decisionsHelper) recordLocalActivityMarker(activityID string, result []byte) decisionStateMachine { markerID := fmt.Sprintf("%v_%v", localActivityMarkerName, activityID) - attributes := &commonproto.RecordMarkerDecisionAttributes{ + attributes := &decisionpb.RecordMarkerDecisionAttributes{ MarkerName: localActivityMarkerName, Details: result, } @@ -815,7 +817,7 @@ func (h *decisionsHelper) recordLocalActivityMarker(activityID string, result [] func (h *decisionsHelper) recordMutableSideEffectMarker(mutableSideEffectID string, data []byte) decisionStateMachine { markerID := fmt.Sprintf("%v_%v", mutableSideEffectMarkerName, mutableSideEffectID) - attributes := &commonproto.RecordMarkerDecisionAttributes{ + attributes := &decisionpb.RecordMarkerDecisionAttributes{ MarkerName: mutableSideEffectMarkerName, Details: data, } @@ -824,7 +826,7 @@ func (h *decisionsHelper) recordMutableSideEffectMarker(mutableSideEffectID stri return decision } -func (h *decisionsHelper) startChildWorkflowExecution(attributes *commonproto.StartChildWorkflowExecutionDecisionAttributes) decisionStateMachine { +func (h *decisionsHelper) startChildWorkflowExecution(attributes *decisionpb.StartChildWorkflowExecutionDecisionAttributes) decisionStateMachine { decision := h.newChildWorkflowDecisionStateMachine(attributes) h.addDecision(decision) return decision @@ -873,7 +875,7 @@ func (h *decisionsHelper) requestCancelExternalWorkflowExecution(namespace, work if len(cancellationID) == 0 { panic("cancellation on external workflow should use cancellation ID") } - attributes := &commonproto.RequestCancelExternalWorkflowExecutionDecisionAttributes{ + attributes := &decisionpb.RequestCancelExternalWorkflowExecutionDecisionAttributes{ Namespace: namespace, WorkflowId: workflowID, RunId: runID, @@ -929,9 +931,9 @@ func (h *decisionsHelper) handleRequestCancelExternalWorkflowExecutionFailed(ini } func (h *decisionsHelper) signalExternalWorkflowExecution(namespace, workflowID, runID, signalName string, input []byte, signalID string, childWorkflowOnly bool) decisionStateMachine { - attributes := &commonproto.SignalExternalWorkflowExecutionDecisionAttributes{ + attributes := &decisionpb.SignalExternalWorkflowExecutionDecisionAttributes{ Namespace: namespace, - Execution: &commonproto.WorkflowExecution{ + Execution: &executionpb.WorkflowExecution{ WorkflowId: workflowID, RunId: runID, }, @@ -945,8 +947,8 @@ func (h *decisionsHelper) signalExternalWorkflowExecution(namespace, workflowID, return decision } -func (h *decisionsHelper) upsertSearchAttributes(upsertID string, searchAttr *commonproto.SearchAttributes) decisionStateMachine { - attributes := &commonproto.UpsertWorkflowSearchAttributesDecisionAttributes{ +func (h *decisionsHelper) upsertSearchAttributes(upsertID string, searchAttr *commonpb.SearchAttributes) decisionStateMachine { + attributes := &decisionpb.UpsertWorkflowSearchAttributesDecisionAttributes{ SearchAttributes: searchAttr, } decision := h.newUpsertSearchAttributesStateMachine(attributes, upsertID) @@ -980,7 +982,7 @@ func (h *decisionsHelper) getSignalID(initiatedEventID int64) string { return signalID } -func (h *decisionsHelper) startTimer(attributes *commonproto.StartTimerDecisionAttributes) decisionStateMachine { +func (h *decisionsHelper) startTimer(attributes *decisionpb.StartTimerDecisionAttributes) decisionStateMachine { decision := h.newTimerDecisionStateMachine(attributes) h.addDecision(decision) return decision @@ -1031,8 +1033,8 @@ func (h *decisionsHelper) handleChildWorkflowExecutionCanceled(workflowID string return decision } -func (h *decisionsHelper) getDecisions(markAsSent bool) []*commonproto.Decision { - var result []*commonproto.Decision +func (h *decisionsHelper) getDecisions(markAsSent bool) []*decisionpb.Decision { + var result []*decisionpb.Decision for curr := h.orderedDecisions.Front(); curr != nil; { next := curr.Next() // get next item here as we might need to remove curr in the loop d := curr.Value.(decisionStateMachine) diff --git a/internal/internal_decision_state_machine_test.go b/internal/internal_decision_state_machine_test.go index c25bd8896..ea1a39ad2 100644 --- a/internal/internal_decision_state_machine_test.go +++ b/internal/internal_decision_state_machine_test.go @@ -25,14 +25,14 @@ import ( "github.com/stretchr/testify/require" - commonproto "go.temporal.io/temporal-proto/common" - "go.temporal.io/temporal-proto/enums" + commonpb "go.temporal.io/temporal-proto/common" + decisionpb "go.temporal.io/temporal-proto/decision" ) func Test_TimerStateMachine_CancelBeforeSent(t *testing.T) { t.Parallel() timerID := "test-timer-1" - attributes := &commonproto.StartTimerDecisionAttributes{ + attributes := &decisionpb.StartTimerDecisionAttributes{ TimerId: timerID, } h := newDecisionsHelper() @@ -47,7 +47,7 @@ func Test_TimerStateMachine_CancelBeforeSent(t *testing.T) { func Test_TimerStateMachine_CancelAfterInitiated(t *testing.T) { t.Parallel() timerID := "test-timer-1" - attributes := &commonproto.StartTimerDecisionAttributes{ + attributes := &decisionpb.StartTimerDecisionAttributes{ TimerId: timerID, } h := newDecisionsHelper() @@ -56,7 +56,7 @@ func Test_TimerStateMachine_CancelAfterInitiated(t *testing.T) { decisions := h.getDecisions(true) require.Equal(t, decisionStateDecisionSent, d.getState()) require.Equal(t, 1, len(decisions)) - require.Equal(t, enums.DecisionTypeStartTimer, decisions[0].GetDecisionType()) + require.Equal(t, decisionpb.DecisionTypeStartTimer, decisions[0].GetDecisionType()) require.Equal(t, attributes, decisions[0].GetStartTimerDecisionAttributes()) h.handleTimerStarted(timerID) require.Equal(t, decisionStateInitiated, d.getState()) @@ -64,7 +64,7 @@ func Test_TimerStateMachine_CancelAfterInitiated(t *testing.T) { require.Equal(t, decisionStateCanceledAfterInitiated, d.getState()) decisions = h.getDecisions(true) require.Equal(t, 1, len(decisions)) - require.Equal(t, enums.DecisionTypeCancelTimer, decisions[0].GetDecisionType()) + require.Equal(t, decisionpb.DecisionTypeCancelTimer, decisions[0].GetDecisionType()) require.Equal(t, decisionStateCancellationDecisionSent, d.getState()) h.handleTimerCanceled(timerID) require.Equal(t, decisionStateCompleted, d.getState()) @@ -73,7 +73,7 @@ func Test_TimerStateMachine_CancelAfterInitiated(t *testing.T) { func Test_TimerStateMachine_CompletedAfterCancel(t *testing.T) { t.Parallel() timerID := "test-timer-1" - attributes := &commonproto.StartTimerDecisionAttributes{ + attributes := &decisionpb.StartTimerDecisionAttributes{ TimerId: timerID, } h := newDecisionsHelper() @@ -82,7 +82,7 @@ func Test_TimerStateMachine_CompletedAfterCancel(t *testing.T) { decisions := h.getDecisions(true) require.Equal(t, decisionStateDecisionSent, d.getState()) require.Equal(t, 1, len(decisions)) - require.Equal(t, enums.DecisionTypeStartTimer, decisions[0].GetDecisionType()) + require.Equal(t, decisionpb.DecisionTypeStartTimer, decisions[0].GetDecisionType()) h.cancelTimer(timerID) require.Equal(t, decisionStateCanceledBeforeInitiated, d.getState()) require.Equal(t, 0, len(h.getDecisions(true))) @@ -90,7 +90,7 @@ func Test_TimerStateMachine_CompletedAfterCancel(t *testing.T) { require.Equal(t, decisionStateCanceledAfterInitiated, d.getState()) decisions = h.getDecisions(true) require.Equal(t, 1, len(decisions)) - require.Equal(t, enums.DecisionTypeCancelTimer, decisions[0].GetDecisionType()) + require.Equal(t, decisionpb.DecisionTypeCancelTimer, decisions[0].GetDecisionType()) require.Equal(t, decisionStateCancellationDecisionSent, d.getState()) h.handleTimerClosed(timerID) require.Equal(t, decisionStateCompletedAfterCancellationDecisionSent, d.getState()) @@ -99,7 +99,7 @@ func Test_TimerStateMachine_CompletedAfterCancel(t *testing.T) { func Test_TimerStateMachine_CompleteWithoutCancel(t *testing.T) { t.Parallel() timerID := "test-timer-1" - attributes := &commonproto.StartTimerDecisionAttributes{ + attributes := &decisionpb.StartTimerDecisionAttributes{ TimerId: timerID, } h := newDecisionsHelper() @@ -108,7 +108,7 @@ func Test_TimerStateMachine_CompleteWithoutCancel(t *testing.T) { decisions := h.getDecisions(true) require.Equal(t, decisionStateDecisionSent, d.getState()) require.Equal(t, 1, len(decisions)) - require.Equal(t, enums.DecisionTypeStartTimer, decisions[0].GetDecisionType()) + require.Equal(t, decisionpb.DecisionTypeStartTimer, decisions[0].GetDecisionType()) h.handleTimerStarted(timerID) require.Equal(t, decisionStateInitiated, d.getState()) require.Equal(t, 0, len(h.getDecisions(false))) @@ -119,7 +119,7 @@ func Test_TimerStateMachine_CompleteWithoutCancel(t *testing.T) { func Test_TimerStateMachine_PanicInvalidStateTransition(t *testing.T) { t.Parallel() timerID := "test-timer-1" - attributes := &commonproto.StartTimerDecisionAttributes{ + attributes := &decisionpb.StartTimerDecisionAttributes{ TimerId: timerID, } h := newDecisionsHelper() @@ -139,7 +139,7 @@ func Test_TimerCancelEventOrdering(t *testing.T) { t.Parallel() timerID := "test-timer-1" localActivityID := "test-activity-1" - attributes := &commonproto.StartTimerDecisionAttributes{ + attributes := &decisionpb.StartTimerDecisionAttributes{ TimerId: timerID, } h := newDecisionsHelper() @@ -148,7 +148,7 @@ func Test_TimerCancelEventOrdering(t *testing.T) { decisions := h.getDecisions(true) require.Equal(t, decisionStateDecisionSent, d.getState()) require.Equal(t, 1, len(decisions)) - require.Equal(t, enums.DecisionTypeStartTimer, decisions[0].GetDecisionType()) + require.Equal(t, decisionpb.DecisionTypeStartTimer, decisions[0].GetDecisionType()) require.Equal(t, attributes, decisions[0].GetStartTimerDecisionAttributes()) h.handleTimerStarted(timerID) require.Equal(t, decisionStateInitiated, d.getState()) @@ -158,14 +158,14 @@ func Test_TimerCancelEventOrdering(t *testing.T) { require.Equal(t, decisionStateCanceledAfterInitiated, d.getState()) decisions = h.getDecisions(true) require.Equal(t, 2, len(decisions)) - require.Equal(t, enums.DecisionTypeRecordMarker, decisions[0].GetDecisionType()) - require.Equal(t, enums.DecisionTypeCancelTimer, decisions[1].GetDecisionType()) + require.Equal(t, decisionpb.DecisionTypeRecordMarker, decisions[0].GetDecisionType()) + require.Equal(t, decisionpb.DecisionTypeCancelTimer, decisions[1].GetDecisionType()) } func Test_ActivityStateMachine_CompleteWithoutCancel(t *testing.T) { t.Parallel() activityID := "test-activity-1" - attributes := &commonproto.ScheduleActivityTaskDecisionAttributes{ + attributes := &decisionpb.ScheduleActivityTaskDecisionAttributes{ ActivityId: activityID, } h := newDecisionsHelper() @@ -176,7 +176,7 @@ func Test_ActivityStateMachine_CompleteWithoutCancel(t *testing.T) { decisions := h.getDecisions(true) require.Equal(t, decisionStateDecisionSent, d.getState()) require.Equal(t, 1, len(decisions)) - require.Equal(t, enums.DecisionTypeScheduleActivityTask, decisions[0].GetDecisionType()) + require.Equal(t, decisionpb.DecisionTypeScheduleActivityTask, decisions[0].GetDecisionType()) // activity scheduled h.handleActivityTaskScheduled(1, activityID) @@ -190,7 +190,7 @@ func Test_ActivityStateMachine_CompleteWithoutCancel(t *testing.T) { func Test_ActivityStateMachine_CancelBeforeSent(t *testing.T) { t.Parallel() activityID := "test-activity-1" - attributes := &commonproto.ScheduleActivityTaskDecisionAttributes{ + attributes := &decisionpb.ScheduleActivityTaskDecisionAttributes{ ActivityId: activityID, } h := newDecisionsHelper() @@ -211,7 +211,7 @@ func Test_ActivityStateMachine_CancelBeforeSent(t *testing.T) { func Test_ActivityStateMachine_CancelAfterSent(t *testing.T) { t.Parallel() activityID := "test-activity-1" - attributes := &commonproto.ScheduleActivityTaskDecisionAttributes{ + attributes := &decisionpb.ScheduleActivityTaskDecisionAttributes{ ActivityId: activityID, } h := newDecisionsHelper() @@ -221,7 +221,7 @@ func Test_ActivityStateMachine_CancelAfterSent(t *testing.T) { require.Equal(t, decisionStateCreated, d.getState()) decisions := h.getDecisions(true) require.Equal(t, 1, len(decisions)) - require.Equal(t, enums.DecisionTypeScheduleActivityTask, decisions[0].GetDecisionType()) + require.Equal(t, decisionpb.DecisionTypeScheduleActivityTask, decisions[0].GetDecisionType()) // cancel activity h.requestCancelActivityTask(activityID) @@ -233,7 +233,7 @@ func Test_ActivityStateMachine_CancelAfterSent(t *testing.T) { require.Equal(t, decisionStateCanceledAfterInitiated, d.getState()) decisions = h.getDecisions(true) require.Equal(t, 1, len(decisions)) - require.Equal(t, enums.DecisionTypeRequestCancelActivityTask, decisions[0].GetDecisionType()) + require.Equal(t, decisionpb.DecisionTypeRequestCancelActivityTask, decisions[0].GetDecisionType()) // activity canceled h.handleActivityTaskCanceled(activityID) @@ -244,7 +244,7 @@ func Test_ActivityStateMachine_CancelAfterSent(t *testing.T) { func Test_ActivityStateMachine_CompletedAfterCancel(t *testing.T) { t.Parallel() activityID := "test-activity-1" - attributes := &commonproto.ScheduleActivityTaskDecisionAttributes{ + attributes := &decisionpb.ScheduleActivityTaskDecisionAttributes{ ActivityId: activityID, } h := newDecisionsHelper() @@ -254,7 +254,7 @@ func Test_ActivityStateMachine_CompletedAfterCancel(t *testing.T) { require.Equal(t, decisionStateCreated, d.getState()) decisions := h.getDecisions(true) require.Equal(t, 1, len(decisions)) - require.Equal(t, enums.DecisionTypeScheduleActivityTask, decisions[0].GetDecisionType()) + require.Equal(t, decisionpb.DecisionTypeScheduleActivityTask, decisions[0].GetDecisionType()) // cancel activity h.requestCancelActivityTask(activityID) @@ -266,7 +266,7 @@ func Test_ActivityStateMachine_CompletedAfterCancel(t *testing.T) { require.Equal(t, decisionStateCanceledAfterInitiated, d.getState()) decisions = h.getDecisions(true) require.Equal(t, 1, len(decisions)) - require.Equal(t, enums.DecisionTypeRequestCancelActivityTask, decisions[0].GetDecisionType()) + require.Equal(t, decisionpb.DecisionTypeRequestCancelActivityTask, decisions[0].GetDecisionType()) // activity completed after cancel h.handleActivityTaskClosed(activityID) @@ -277,7 +277,7 @@ func Test_ActivityStateMachine_CompletedAfterCancel(t *testing.T) { func Test_ActivityStateMachine_PanicInvalidStateTransition(t *testing.T) { t.Parallel() activityID := "test-activity-1" - attributes := &commonproto.ScheduleActivityTaskDecisionAttributes{ + attributes := &decisionpb.ScheduleActivityTaskDecisionAttributes{ ActivityId: activityID, } h := newDecisionsHelper() @@ -306,7 +306,7 @@ func Test_ActivityStateMachine_PanicInvalidStateTransition(t *testing.T) { func Test_ChildWorkflowStateMachine_Basic(t *testing.T) { t.Parallel() workflowID := "test-child-workflow-1" - attributes := &commonproto.StartChildWorkflowExecutionDecisionAttributes{ + attributes := &decisionpb.StartChildWorkflowExecutionDecisionAttributes{ WorkflowId: workflowID, } h := newDecisionsHelper() @@ -319,7 +319,7 @@ func Test_ChildWorkflowStateMachine_Basic(t *testing.T) { decisions := h.getDecisions(true) require.Equal(t, decisionStateDecisionSent, d.getState()) require.Equal(t, 1, len(decisions)) - require.Equal(t, enums.DecisionTypeStartChildWorkflowExecution, decisions[0].GetDecisionType()) + require.Equal(t, decisionpb.DecisionTypeStartChildWorkflowExecution, decisions[0].GetDecisionType()) // child workflow initiated h.handleStartChildWorkflowExecutionInitiated(workflowID) @@ -344,7 +344,7 @@ func Test_ChildWorkflowStateMachine_CancelSucceed(t *testing.T) { runID := "" cancellationID := "" initiatedEventID := int64(28) - attributes := &commonproto.StartChildWorkflowExecutionDecisionAttributes{ + attributes := &decisionpb.StartChildWorkflowExecutionDecisionAttributes{ WorkflowId: workflowID, } h := newDecisionsHelper() @@ -366,7 +366,7 @@ func Test_ChildWorkflowStateMachine_CancelSucceed(t *testing.T) { decisions := h.getDecisions(true) require.Equal(t, decisionStateCancellationDecisionSent, d.getState()) require.Equal(t, 1, len(decisions)) - require.Equal(t, enums.DecisionTypeRequestCancelExternalWorkflowExecution, decisions[0].GetDecisionType()) + require.Equal(t, decisionpb.DecisionTypeRequestCancelExternalWorkflowExecution, decisions[0].GetDecisionType()) // cancel request initiated h.handleRequestCancelExternalWorkflowExecutionInitiated(initiatedEventID, workflowID, cancellationID) @@ -386,7 +386,7 @@ func Test_ChildWorkflowStateMachine_InvalidStates(t *testing.T) { namespace := "test-namespace" workflowID := "test-workflow-id" runID := "" - attributes := &commonproto.StartChildWorkflowExecutionDecisionAttributes{ + attributes := &decisionpb.StartChildWorkflowExecutionDecisionAttributes{ WorkflowId: workflowID, } cancellationID := "" @@ -434,7 +434,7 @@ func Test_ChildWorkflowStateMachine_InvalidStates(t *testing.T) { decisions = h.getDecisions(true) require.Equal(t, decisionStateCancellationDecisionSent, d.getState()) require.Equal(t, 1, len(decisions)) - require.Equal(t, enums.DecisionTypeRequestCancelExternalWorkflowExecution, decisions[0].GetDecisionType()) + require.Equal(t, decisionpb.DecisionTypeRequestCancelExternalWorkflowExecution, decisions[0].GetDecisionType()) // invalid: start child workflow failed after it was already started err = runAndCatchPanic(func() { @@ -468,7 +468,7 @@ func Test_ChildWorkflowStateMachine_CancelFailed(t *testing.T) { namespace := "test-namespace" workflowID := "test-workflow-id" runID := "" - attributes := &commonproto.StartChildWorkflowExecutionDecisionAttributes{ + attributes := &decisionpb.StartChildWorkflowExecutionDecisionAttributes{ WorkflowId: workflowID, } cancellationID := "" @@ -511,21 +511,21 @@ func Test_MarkerStateMachine(t *testing.T) { decisions := h.getDecisions(true) require.Equal(t, decisionStateCompleted, d.getState()) require.Equal(t, 1, len(decisions)) - require.Equal(t, enums.DecisionTypeRecordMarker, decisions[0].GetDecisionType()) + require.Equal(t, decisionpb.DecisionTypeRecordMarker, decisions[0].GetDecisionType()) } func Test_UpsertSearchAttributesDecisionStateMachine(t *testing.T) { t.Parallel() h := newDecisionsHelper() - attr := &commonproto.SearchAttributes{} + attr := &commonpb.SearchAttributes{} d := h.upsertSearchAttributes("1", attr) require.Equal(t, decisionStateCreated, d.getState()) decisions := h.getDecisions(true) require.Equal(t, decisionStateCompleted, d.getState()) require.Equal(t, 1, len(decisions)) - require.Equal(t, enums.DecisionTypeUpsertWorkflowSearchAttributes, decisions[0].GetDecisionType()) + require.Equal(t, decisionpb.DecisionTypeUpsertWorkflowSearchAttributes, decisions[0].GetDecisionType()) } func Test_CancelExternalWorkflowStateMachine_Succeed(t *testing.T) { @@ -546,10 +546,10 @@ func Test_CancelExternalWorkflowStateMachine_Succeed(t *testing.T) { // send decisions decisions := h.getDecisions(true) require.Equal(t, 1, len(decisions)) - require.Equal(t, enums.DecisionTypeRequestCancelExternalWorkflowExecution, decisions[0].GetDecisionType()) + require.Equal(t, decisionpb.DecisionTypeRequestCancelExternalWorkflowExecution, decisions[0].GetDecisionType()) require.Equal( t, - &commonproto.RequestCancelExternalWorkflowExecutionDecisionAttributes{ + &decisionpb.RequestCancelExternalWorkflowExecutionDecisionAttributes{ Namespace: namespace, WorkflowId: workflowID, RunId: runID, @@ -592,10 +592,10 @@ func Test_CancelExternalWorkflowStateMachine_Failed(t *testing.T) { // send decisions decisions := h.getDecisions(true) require.Equal(t, 1, len(decisions)) - require.Equal(t, enums.DecisionTypeRequestCancelExternalWorkflowExecution, decisions[0].GetDecisionType()) + require.Equal(t, decisionpb.DecisionTypeRequestCancelExternalWorkflowExecution, decisions[0].GetDecisionType()) require.Equal( t, - &commonproto.RequestCancelExternalWorkflowExecutionDecisionAttributes{ + &decisionpb.RequestCancelExternalWorkflowExecutionDecisionAttributes{ Namespace: namespace, WorkflowId: workflowID, RunId: runID, diff --git a/internal/internal_event_handlers.go b/internal/internal_event_handlers.go index f807c8508..648473c75 100644 --- a/internal/internal_event_handlers.go +++ b/internal/internal_event_handlers.go @@ -32,9 +32,12 @@ import ( "github.com/opentracing/opentracing-go" "github.com/uber-go/tally" - commonproto "go.temporal.io/temporal-proto/common" - "go.temporal.io/temporal-proto/enums" + + commonpb "go.temporal.io/temporal-proto/common" + decisionpb "go.temporal.io/temporal-proto/decision" + eventpb "go.temporal.io/temporal-proto/event" "go.temporal.io/temporal-proto/serviceerror" + tasklistpb "go.temporal.io/temporal-proto/tasklist" "go.uber.org/zap" "go.uber.org/zap/zapcore" @@ -309,16 +312,16 @@ func (wc *workflowEnvironmentImpl) UpsertSearchAttributes(attributes map[string] return nil } -func (wc *workflowEnvironmentImpl) updateWorkflowInfoWithSearchAttributes(attributes *commonproto.SearchAttributes) { +func (wc *workflowEnvironmentImpl) updateWorkflowInfoWithSearchAttributes(attributes *commonpb.SearchAttributes) { wc.workflowInfo.SearchAttributes = mergeSearchAttributes(wc.workflowInfo.SearchAttributes, attributes) } -func mergeSearchAttributes(current, upsert *commonproto.SearchAttributes) *commonproto.SearchAttributes { +func mergeSearchAttributes(current, upsert *commonpb.SearchAttributes) *commonpb.SearchAttributes { if current == nil || len(current.IndexedFields) == 0 { if upsert == nil || len(upsert.IndexedFields) == 0 { return nil } - current = &commonproto.SearchAttributes{ + current = &commonpb.SearchAttributes{ IndexedFields: make(map[string][]byte), } } @@ -330,7 +333,7 @@ func mergeSearchAttributes(current, upsert *commonproto.SearchAttributes) *commo return current } -func validateAndSerializeSearchAttributes(attributes map[string]interface{}) (*commonproto.SearchAttributes, error) { +func validateAndSerializeSearchAttributes(attributes map[string]interface{}) (*commonpb.SearchAttributes, error) { if len(attributes) == 0 { return nil, errSearchAttributesNotSet } @@ -359,15 +362,15 @@ func (wc *workflowEnvironmentImpl) ExecuteChildWorkflow( return err } - attributes := &commonproto.StartChildWorkflowExecutionDecisionAttributes{} + attributes := &decisionpb.StartChildWorkflowExecutionDecisionAttributes{} attributes.Namespace = params.namespace - attributes.TaskList = &commonproto.TaskList{Name: params.taskListName} + attributes.TaskList = &tasklistpb.TaskList{Name: params.taskListName} attributes.WorkflowId = params.workflowID attributes.ExecutionStartToCloseTimeoutSeconds = params.executionStartToCloseTimeoutSeconds attributes.TaskStartToCloseTimeoutSeconds = params.taskStartToCloseTimeoutSeconds attributes.Input = params.input - attributes.WorkflowType = &commonproto.WorkflowType{Name: params.workflowType.Name} + attributes.WorkflowType = &commonpb.WorkflowType{Name: params.workflowType.Name} attributes.WorkflowIdReusePolicy = params.workflowIDReusePolicy.toProto() attributes.ParentClosePolicy = params.parentClosePolicy.toProto() attributes.RetryPolicy = params.retryPolicy @@ -430,22 +433,22 @@ func (wc *workflowEnvironmentImpl) GenerateSequence() int32 { return result } -func (wc *workflowEnvironmentImpl) CreateNewDecision(decisionType enums.DecisionType) *commonproto.Decision { - return &commonproto.Decision{ +func (wc *workflowEnvironmentImpl) CreateNewDecision(decisionType decisionpb.DecisionType) *decisionpb.Decision { + return &decisionpb.Decision{ DecisionType: decisionType, } } func (wc *workflowEnvironmentImpl) ExecuteActivity(parameters executeActivityParams, callback resultHandler) *activityInfo { - scheduleTaskAttr := &commonproto.ScheduleActivityTaskDecisionAttributes{} + scheduleTaskAttr := &decisionpb.ScheduleActivityTaskDecisionAttributes{} if parameters.ActivityID == "" { scheduleTaskAttr.ActivityId = wc.GenerateSequenceID() } else { scheduleTaskAttr.ActivityId = parameters.ActivityID } activityID := scheduleTaskAttr.GetActivityId() - scheduleTaskAttr.ActivityType = &commonproto.ActivityType{Name: parameters.ActivityType.Name} - scheduleTaskAttr.TaskList = &commonproto.TaskList{Name: parameters.TaskListName} + scheduleTaskAttr.ActivityType = &commonpb.ActivityType{Name: parameters.ActivityType.Name} + scheduleTaskAttr.TaskList = &tasklistpb.TaskList{Name: parameters.TaskListName} scheduleTaskAttr.Input = parameters.Input scheduleTaskAttr.ScheduleToCloseTimeoutSeconds = parameters.ScheduleToCloseTimeoutSeconds scheduleTaskAttr.StartToCloseTimeoutSeconds = parameters.StartToCloseTimeoutSeconds @@ -534,7 +537,7 @@ func (wc *workflowEnvironmentImpl) NewTimer(d time.Duration, callback resultHand } timerID := wc.GenerateSequenceID() - startTimerAttr := &commonproto.StartTimerDecisionAttributes{} + startTimerAttr := &decisionpb.StartTimerDecisionAttributes{} startTimerAttr.TimerId = timerID startTimerAttr.StartToFireTimeoutSeconds = common.Int64Ceil(d.Seconds()) @@ -737,7 +740,7 @@ func (wc *workflowEnvironmentImpl) GetRegistry() *registry { } func (weh *workflowExecutionEventHandlerImpl) ProcessEvent( - event *commonproto.HistoryEvent, + event *eventpb.HistoryEvent, isReplay bool, isLast bool, ) (err error) { @@ -765,127 +768,127 @@ func (weh *workflowExecutionEventHandlerImpl) ProcessEvent( }) switch event.GetEventType() { - case enums.EventTypeWorkflowExecutionStarted: + case eventpb.EventTypeWorkflowExecutionStarted: err = weh.handleWorkflowExecutionStarted(event.GetWorkflowExecutionStartedEventAttributes()) - case enums.EventTypeWorkflowExecutionCompleted: + case eventpb.EventTypeWorkflowExecutionCompleted: // No Operation - case enums.EventTypeWorkflowExecutionFailed: + case eventpb.EventTypeWorkflowExecutionFailed: // No Operation - case enums.EventTypeWorkflowExecutionTimedOut: + case eventpb.EventTypeWorkflowExecutionTimedOut: // No Operation - case enums.EventTypeDecisionTaskScheduled: + case eventpb.EventTypeDecisionTaskScheduled: // No Operation - case enums.EventTypeDecisionTaskStarted: + case eventpb.EventTypeDecisionTaskStarted: // Set replay clock. weh.SetCurrentReplayTime(time.Unix(0, event.GetTimestamp())) weh.workflowDefinition.OnDecisionTaskStarted() - case enums.EventTypeDecisionTaskTimedOut: + case eventpb.EventTypeDecisionTaskTimedOut: // No Operation - case enums.EventTypeDecisionTaskFailed: + case eventpb.EventTypeDecisionTaskFailed: // No Operation - case enums.EventTypeDecisionTaskCompleted: + case eventpb.EventTypeDecisionTaskCompleted: // No Operation - case enums.EventTypeActivityTaskScheduled: + case eventpb.EventTypeActivityTaskScheduled: weh.decisionsHelper.handleActivityTaskScheduled( event.GetEventId(), event.GetActivityTaskScheduledEventAttributes().GetActivityId()) - case enums.EventTypeActivityTaskStarted: + case eventpb.EventTypeActivityTaskStarted: // No Operation - case enums.EventTypeActivityTaskCompleted: + case eventpb.EventTypeActivityTaskCompleted: err = weh.handleActivityTaskCompleted(event) - case enums.EventTypeActivityTaskFailed: + case eventpb.EventTypeActivityTaskFailed: err = weh.handleActivityTaskFailed(event) - case enums.EventTypeActivityTaskTimedOut: + case eventpb.EventTypeActivityTaskTimedOut: err = weh.handleActivityTaskTimedOut(event) - case enums.EventTypeActivityTaskCancelRequested: + case eventpb.EventTypeActivityTaskCancelRequested: weh.decisionsHelper.handleActivityTaskCancelRequested( event.GetActivityTaskCancelRequestedEventAttributes().GetActivityId()) - case enums.EventTypeRequestCancelActivityTaskFailed: + case eventpb.EventTypeRequestCancelActivityTaskFailed: weh.decisionsHelper.handleRequestCancelActivityTaskFailed( event.GetRequestCancelActivityTaskFailedEventAttributes().GetActivityId()) - case enums.EventTypeActivityTaskCanceled: + case eventpb.EventTypeActivityTaskCanceled: err = weh.handleActivityTaskCanceled(event) - case enums.EventTypeTimerStarted: + case eventpb.EventTypeTimerStarted: weh.decisionsHelper.handleTimerStarted(event.GetTimerStartedEventAttributes().GetTimerId()) - case enums.EventTypeTimerFired: + case eventpb.EventTypeTimerFired: weh.handleTimerFired(event) - case enums.EventTypeTimerCanceled: + case eventpb.EventTypeTimerCanceled: weh.decisionsHelper.handleTimerCanceled(event.GetTimerCanceledEventAttributes().GetTimerId()) - case enums.EventTypeCancelTimerFailed: + case eventpb.EventTypeCancelTimerFailed: weh.decisionsHelper.handleCancelTimerFailed(event.GetCancelTimerFailedEventAttributes().GetTimerId()) - case enums.EventTypeWorkflowExecutionCancelRequested: + case eventpb.EventTypeWorkflowExecutionCancelRequested: weh.handleWorkflowExecutionCancelRequested() - case enums.EventTypeWorkflowExecutionCanceled: + case eventpb.EventTypeWorkflowExecutionCanceled: // No Operation. - case enums.EventTypeRequestCancelExternalWorkflowExecutionInitiated: + case eventpb.EventTypeRequestCancelExternalWorkflowExecutionInitiated: _ = weh.handleRequestCancelExternalWorkflowExecutionInitiated(event) - case enums.EventTypeRequestCancelExternalWorkflowExecutionFailed: + case eventpb.EventTypeRequestCancelExternalWorkflowExecutionFailed: _ = weh.handleRequestCancelExternalWorkflowExecutionFailed(event) - case enums.EventTypeExternalWorkflowExecutionCancelRequested: + case eventpb.EventTypeExternalWorkflowExecutionCancelRequested: _ = weh.handleExternalWorkflowExecutionCancelRequested(event) - case enums.EventTypeWorkflowExecutionContinuedAsNew: + case eventpb.EventTypeWorkflowExecutionContinuedAsNew: // No Operation. - case enums.EventTypeWorkflowExecutionSignaled: + case eventpb.EventTypeWorkflowExecutionSignaled: weh.handleWorkflowExecutionSignaled(event.GetWorkflowExecutionSignaledEventAttributes()) - case enums.EventTypeSignalExternalWorkflowExecutionInitiated: + case eventpb.EventTypeSignalExternalWorkflowExecutionInitiated: signalID := string(event.GetSignalExternalWorkflowExecutionInitiatedEventAttributes().Control) weh.decisionsHelper.handleSignalExternalWorkflowExecutionInitiated(event.GetEventId(), signalID) - case enums.EventTypeSignalExternalWorkflowExecutionFailed: + case eventpb.EventTypeSignalExternalWorkflowExecutionFailed: _ = weh.handleSignalExternalWorkflowExecutionFailed(event) - case enums.EventTypeExternalWorkflowExecutionSignaled: + case eventpb.EventTypeExternalWorkflowExecutionSignaled: _ = weh.handleSignalExternalWorkflowExecutionCompleted(event) - case enums.EventTypeMarkerRecorded: + case eventpb.EventTypeMarkerRecorded: err = weh.handleMarkerRecorded(event.GetEventId(), event.GetMarkerRecordedEventAttributes()) - case enums.EventTypeStartChildWorkflowExecutionInitiated: + case eventpb.EventTypeStartChildWorkflowExecutionInitiated: weh.decisionsHelper.handleStartChildWorkflowExecutionInitiated( event.GetStartChildWorkflowExecutionInitiatedEventAttributes().GetWorkflowId()) - case enums.EventTypeStartChildWorkflowExecutionFailed: + case eventpb.EventTypeStartChildWorkflowExecutionFailed: err = weh.handleStartChildWorkflowExecutionFailed(event) - case enums.EventTypeChildWorkflowExecutionStarted: + case eventpb.EventTypeChildWorkflowExecutionStarted: err = weh.handleChildWorkflowExecutionStarted(event) - case enums.EventTypeChildWorkflowExecutionCompleted: + case eventpb.EventTypeChildWorkflowExecutionCompleted: err = weh.handleChildWorkflowExecutionCompleted(event) - case enums.EventTypeChildWorkflowExecutionFailed: + case eventpb.EventTypeChildWorkflowExecutionFailed: err = weh.handleChildWorkflowExecutionFailed(event) - case enums.EventTypeChildWorkflowExecutionCanceled: + case eventpb.EventTypeChildWorkflowExecutionCanceled: err = weh.handleChildWorkflowExecutionCanceled(event) - case enums.EventTypeChildWorkflowExecutionTimedOut: + case eventpb.EventTypeChildWorkflowExecutionTimedOut: err = weh.handleChildWorkflowExecutionTimedOut(event) - case enums.EventTypeChildWorkflowExecutionTerminated: + case eventpb.EventTypeChildWorkflowExecutionTerminated: err = weh.handleChildWorkflowExecutionTerminated(event) - case enums.EventTypeUpsertWorkflowSearchAttributes: + case eventpb.EventTypeUpsertWorkflowSearchAttributes: weh.handleUpsertWorkflowSearchAttributes(event) default: @@ -902,7 +905,7 @@ func (weh *workflowExecutionEventHandlerImpl) ProcessEvent( // When replaying histories to get stack trace or current state the last event might be not // decision started. So always call OnDecisionTaskStarted on the last event. // Don't call for EventType_DecisionTaskStarted as it was already called when handling it. - if isLast && event.GetEventType() != enums.EventTypeDecisionTaskStarted { + if isLast && event.GetEventType() != eventpb.EventTypeDecisionTaskStarted { weh.workflowDefinition.OnDecisionTaskStarted() } @@ -945,7 +948,7 @@ func (weh *workflowExecutionEventHandlerImpl) Close() { } func (weh *workflowExecutionEventHandlerImpl) handleWorkflowExecutionStarted( - attributes *commonproto.WorkflowExecutionStartedEventAttributes) (err error) { + attributes *eventpb.WorkflowExecutionStartedEventAttributes) (err error) { weh.workflowDefinition, err = weh.registry.getWorkflowDefinition( weh.workflowInfo.WorkflowType, ) @@ -958,7 +961,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleWorkflowExecutionStarted( return nil } -func (weh *workflowExecutionEventHandlerImpl) handleActivityTaskCompleted(event *commonproto.HistoryEvent) error { +func (weh *workflowExecutionEventHandlerImpl) handleActivityTaskCompleted(event *eventpb.HistoryEvent) error { activityID := weh.decisionsHelper.getActivityID(event) decision := weh.decisionsHelper.handleActivityTaskClosed(activityID) activity := decision.getData().(*scheduledActivity) @@ -970,7 +973,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleActivityTaskCompleted(event return nil } -func (weh *workflowExecutionEventHandlerImpl) handleActivityTaskFailed(event *commonproto.HistoryEvent) error { +func (weh *workflowExecutionEventHandlerImpl) handleActivityTaskFailed(event *eventpb.HistoryEvent) error { activityID := weh.decisionsHelper.getActivityID(event) decision := weh.decisionsHelper.handleActivityTaskClosed(activityID) activity := decision.getData().(*scheduledActivity) @@ -984,7 +987,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleActivityTaskFailed(event *co return nil } -func (weh *workflowExecutionEventHandlerImpl) handleActivityTaskTimedOut(event *commonproto.HistoryEvent) error { +func (weh *workflowExecutionEventHandlerImpl) handleActivityTaskTimedOut(event *eventpb.HistoryEvent) error { activityID := weh.decisionsHelper.getActivityID(event) decision := weh.decisionsHelper.handleActivityTaskClosed(activityID) activity := decision.getData().(*scheduledActivity) @@ -994,7 +997,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleActivityTaskTimedOut(event * var err error attributes := event.GetActivityTaskTimedOutEventAttributes() - if len(attributes.GetLastFailureReason()) > 0 && attributes.GetTimeoutType() == enums.TimeoutTypeStartToClose { + if len(attributes.GetLastFailureReason()) > 0 && attributes.GetTimeoutType() == eventpb.TimeoutTypeStartToClose { // When retry activity timeout, it is possible that previous attempts got other customer timeout errors. // To stabilize the error type, we always return the customer error. // See more details of background: https://github.com/temporalio/temporal/issues/185 @@ -1007,7 +1010,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleActivityTaskTimedOut(event * return nil } -func (weh *workflowExecutionEventHandlerImpl) handleActivityTaskCanceled(event *commonproto.HistoryEvent) error { +func (weh *workflowExecutionEventHandlerImpl) handleActivityTaskCanceled(event *eventpb.HistoryEvent) error { activityID := weh.decisionsHelper.getActivityID(event) decision := weh.decisionsHelper.handleActivityTaskCanceled(activityID) activity := decision.getData().(*scheduledActivity) @@ -1025,7 +1028,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleActivityTaskCanceled(event * return nil } -func (weh *workflowExecutionEventHandlerImpl) handleTimerFired(event *commonproto.HistoryEvent) { +func (weh *workflowExecutionEventHandlerImpl) handleTimerFired(event *eventpb.HistoryEvent) { timerID := event.GetTimerFiredEventAttributes().GetTimerId() decision := weh.decisionsHelper.handleTimerClosed(timerID) timer := decision.getData().(*scheduledTimer) @@ -1042,7 +1045,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleWorkflowExecutionCancelReque func (weh *workflowExecutionEventHandlerImpl) handleMarkerRecorded( eventID int64, - attributes *commonproto.MarkerRecordedEventAttributes, + attributes *eventpb.MarkerRecordedEventAttributes, ) error { encodedValues := newEncodedValues(attributes.Details, weh.dataConverter) switch attributes.GetMarkerName() { @@ -1131,9 +1134,9 @@ func (weh *workflowExecutionEventHandlerImpl) ProcessLocalActivityResult(lar *lo } // create marker event for local activity result - markerEvent := &commonproto.HistoryEvent{ - EventType: enums.EventTypeMarkerRecorded, - Attributes: &commonproto.HistoryEvent_MarkerRecordedEventAttributes{MarkerRecordedEventAttributes: &commonproto.MarkerRecordedEventAttributes{ + markerEvent := &eventpb.HistoryEvent{ + EventType: eventpb.EventTypeMarkerRecorded, + Attributes: &eventpb.HistoryEvent_MarkerRecordedEventAttributes{MarkerRecordedEventAttributes: &eventpb.MarkerRecordedEventAttributes{ MarkerName: localActivityMarkerName, Details: markerData, }}, @@ -1144,11 +1147,11 @@ func (weh *workflowExecutionEventHandlerImpl) ProcessLocalActivityResult(lar *lo } func (weh *workflowExecutionEventHandlerImpl) handleWorkflowExecutionSignaled( - attributes *commonproto.WorkflowExecutionSignaledEventAttributes) { + attributes *eventpb.WorkflowExecutionSignaledEventAttributes) { weh.signalHandler(attributes.GetSignalName(), attributes.Input) } -func (weh *workflowExecutionEventHandlerImpl) handleStartChildWorkflowExecutionFailed(event *commonproto.HistoryEvent) error { +func (weh *workflowExecutionEventHandlerImpl) handleStartChildWorkflowExecutionFailed(event *eventpb.HistoryEvent) error { attributes := event.GetStartChildWorkflowExecutionFailedEventAttributes() childWorkflowID := attributes.GetWorkflowId() decision := weh.decisionsHelper.handleStartChildWorkflowExecutionFailed(childWorkflowID) @@ -1163,7 +1166,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleStartChildWorkflowExecutionF return nil } -func (weh *workflowExecutionEventHandlerImpl) handleChildWorkflowExecutionStarted(event *commonproto.HistoryEvent) error { +func (weh *workflowExecutionEventHandlerImpl) handleChildWorkflowExecutionStarted(event *eventpb.HistoryEvent) error { attributes := event.GetChildWorkflowExecutionStartedEventAttributes() childWorkflowID := attributes.WorkflowExecution.GetWorkflowId() childRunID := attributes.WorkflowExecution.GetRunId() @@ -1182,7 +1185,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleChildWorkflowExecutionStarte return nil } -func (weh *workflowExecutionEventHandlerImpl) handleChildWorkflowExecutionCompleted(event *commonproto.HistoryEvent) error { +func (weh *workflowExecutionEventHandlerImpl) handleChildWorkflowExecutionCompleted(event *eventpb.HistoryEvent) error { attributes := event.GetChildWorkflowExecutionCompletedEventAttributes() childWorkflowID := attributes.WorkflowExecution.GetWorkflowId() decision := weh.decisionsHelper.handleChildWorkflowExecutionClosed(childWorkflowID) @@ -1195,7 +1198,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleChildWorkflowExecutionComple return nil } -func (weh *workflowExecutionEventHandlerImpl) handleChildWorkflowExecutionFailed(event *commonproto.HistoryEvent) error { +func (weh *workflowExecutionEventHandlerImpl) handleChildWorkflowExecutionFailed(event *eventpb.HistoryEvent) error { attributes := event.GetChildWorkflowExecutionFailedEventAttributes() childWorkflowID := attributes.WorkflowExecution.GetWorkflowId() decision := weh.decisionsHelper.handleChildWorkflowExecutionClosed(childWorkflowID) @@ -1210,7 +1213,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleChildWorkflowExecutionFailed return nil } -func (weh *workflowExecutionEventHandlerImpl) handleChildWorkflowExecutionCanceled(event *commonproto.HistoryEvent) error { +func (weh *workflowExecutionEventHandlerImpl) handleChildWorkflowExecutionCanceled(event *eventpb.HistoryEvent) error { attributes := event.GetChildWorkflowExecutionCanceledEventAttributes() childWorkflowID := attributes.WorkflowExecution.GetWorkflowId() decision := weh.decisionsHelper.handleChildWorkflowExecutionCanceled(childWorkflowID) @@ -1224,7 +1227,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleChildWorkflowExecutionCancel return nil } -func (weh *workflowExecutionEventHandlerImpl) handleChildWorkflowExecutionTimedOut(event *commonproto.HistoryEvent) error { +func (weh *workflowExecutionEventHandlerImpl) handleChildWorkflowExecutionTimedOut(event *eventpb.HistoryEvent) error { attributes := event.GetChildWorkflowExecutionTimedOutEventAttributes() childWorkflowID := attributes.WorkflowExecution.GetWorkflowId() decision := weh.decisionsHelper.handleChildWorkflowExecutionClosed(childWorkflowID) @@ -1238,7 +1241,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleChildWorkflowExecutionTimedO return nil } -func (weh *workflowExecutionEventHandlerImpl) handleChildWorkflowExecutionTerminated(event *commonproto.HistoryEvent) error { +func (weh *workflowExecutionEventHandlerImpl) handleChildWorkflowExecutionTerminated(event *eventpb.HistoryEvent) error { attributes := event.GetChildWorkflowExecutionTerminatedEventAttributes() childWorkflowID := attributes.WorkflowExecution.GetWorkflowId() decision := weh.decisionsHelper.handleChildWorkflowExecutionClosed(childWorkflowID) @@ -1252,11 +1255,11 @@ func (weh *workflowExecutionEventHandlerImpl) handleChildWorkflowExecutionTermin return nil } -func (weh *workflowExecutionEventHandlerImpl) handleUpsertWorkflowSearchAttributes(event *commonproto.HistoryEvent) { +func (weh *workflowExecutionEventHandlerImpl) handleUpsertWorkflowSearchAttributes(event *eventpb.HistoryEvent) { weh.updateWorkflowInfoWithSearchAttributes(event.GetUpsertWorkflowSearchAttributesEventAttributes().SearchAttributes) } -func (weh *workflowExecutionEventHandlerImpl) handleRequestCancelExternalWorkflowExecutionInitiated(event *commonproto.HistoryEvent) error { +func (weh *workflowExecutionEventHandlerImpl) handleRequestCancelExternalWorkflowExecutionInitiated(event *eventpb.HistoryEvent) error { // For cancellation of child workflow only, we do not use cancellation ID // for cancellation of external workflow, we have to use cancellation ID attribute := event.GetRequestCancelExternalWorkflowExecutionInitiatedEventAttributes() @@ -1266,7 +1269,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleRequestCancelExternalWorkflo return nil } -func (weh *workflowExecutionEventHandlerImpl) handleExternalWorkflowExecutionCancelRequested(event *commonproto.HistoryEvent) error { +func (weh *workflowExecutionEventHandlerImpl) handleExternalWorkflowExecutionCancelRequested(event *eventpb.HistoryEvent) error { // For cancellation of child workflow only, we do not use cancellation ID // for cancellation of external workflow, we have to use cancellation ID attributes := event.GetExternalWorkflowExecutionCancelRequestedEventAttributes() @@ -1284,7 +1287,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleExternalWorkflowExecutionCan return nil } -func (weh *workflowExecutionEventHandlerImpl) handleRequestCancelExternalWorkflowExecutionFailed(event *commonproto.HistoryEvent) error { +func (weh *workflowExecutionEventHandlerImpl) handleRequestCancelExternalWorkflowExecutionFailed(event *eventpb.HistoryEvent) error { // For cancellation of child workflow only, we do not use cancellation ID // for cancellation of external workflow, we have to use cancellation ID attributes := event.GetRequestCancelExternalWorkflowExecutionFailedEventAttributes() @@ -1303,7 +1306,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleRequestCancelExternalWorkflo return nil } -func (weh *workflowExecutionEventHandlerImpl) handleSignalExternalWorkflowExecutionCompleted(event *commonproto.HistoryEvent) error { +func (weh *workflowExecutionEventHandlerImpl) handleSignalExternalWorkflowExecutionCompleted(event *eventpb.HistoryEvent) error { attributes := event.GetExternalWorkflowExecutionSignaledEventAttributes() decision := weh.decisionsHelper.handleSignalExternalWorkflowExecutionCompleted(attributes.GetInitiatedEventId()) signal := decision.getData().(*scheduledSignal) @@ -1315,7 +1318,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleSignalExternalWorkflowExecut return nil } -func (weh *workflowExecutionEventHandlerImpl) handleSignalExternalWorkflowExecutionFailed(event *commonproto.HistoryEvent) error { +func (weh *workflowExecutionEventHandlerImpl) handleSignalExternalWorkflowExecutionFailed(event *eventpb.HistoryEvent) error { attributes := event.GetSignalExternalWorkflowExecutionFailedEventAttributes() decision := weh.decisionsHelper.handleSignalExternalWorkflowExecutionFailed(attributes.GetInitiatedEventId()) signal := decision.getData().(*scheduledSignal) @@ -1325,7 +1328,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleSignalExternalWorkflowExecut var err error switch attributes.GetCause() { - case enums.SignalExternalWorkflowExecutionFailedCauseUnknownExternalWorkflowExecution: + case eventpb.SignalExternalWorkflowExecutionFailedCauseUnknownExternalWorkflowExecution: err = newUnknownExternalWorkflowExecutionError() default: err = fmt.Errorf("signal external workflow failed, %v", attributes.GetCause()) diff --git a/internal/internal_event_handlers_test.go b/internal/internal_event_handlers_test.go index fa6b02efe..10b1bb1d3 100644 --- a/internal/internal_event_handlers_test.go +++ b/internal/internal_event_handlers_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - commonproto "go.temporal.io/temporal-proto/common" + commonpb "go.temporal.io/temporal-proto/common" "go.uber.org/zap" "go.uber.org/zap/zapcore" "go.uber.org/zap/zaptest/observer" @@ -187,37 +187,37 @@ func Test_MergeSearchAttributes(t *testing.T) { t.Parallel() tests := []struct { name string - current *commonproto.SearchAttributes - upsert *commonproto.SearchAttributes - expected *commonproto.SearchAttributes + current *commonpb.SearchAttributes + upsert *commonpb.SearchAttributes + expected *commonpb.SearchAttributes }{ { name: "currentIsNil", current: nil, - upsert: &commonproto.SearchAttributes{}, + upsert: &commonpb.SearchAttributes{}, expected: nil, }, { name: "currentIsEmpty", - current: &commonproto.SearchAttributes{IndexedFields: make(map[string][]byte)}, - upsert: &commonproto.SearchAttributes{}, + current: &commonpb.SearchAttributes{IndexedFields: make(map[string][]byte)}, + upsert: &commonpb.SearchAttributes{}, expected: nil, }, { name: "normalMerge", - current: &commonproto.SearchAttributes{ + current: &commonpb.SearchAttributes{ IndexedFields: map[string][]byte{ "CustomIntField": []byte(`1`), "CustomKeywordField": []byte(`keyword`), }, }, - upsert: &commonproto.SearchAttributes{ + upsert: &commonpb.SearchAttributes{ IndexedFields: map[string][]byte{ "CustomIntField": []byte(`2`), "CustomBoolField": []byte(`true`), }, }, - expected: &commonproto.SearchAttributes{ + expected: &commonpb.SearchAttributes{ IndexedFields: map[string][]byte{ "CustomIntField": []byte(`2`), "CustomKeywordField": []byte(`keyword`), diff --git a/internal/internal_public.go b/internal/internal_public.go index 1e248137f..db158dcd8 100644 --- a/internal/internal_public.go +++ b/internal/internal_public.go @@ -30,7 +30,7 @@ package internal import ( "time" - commonproto "go.temporal.io/temporal-proto/common" + eventpb "go.temporal.io/temporal-proto/event" "go.temporal.io/temporal-proto/workflowservice" ) @@ -40,7 +40,7 @@ type ( // HistoryIterator iterator through history events HistoryIterator interface { // GetNextPage returns next page of history events - GetNextPage() (*commonproto.History, error) + GetNextPage() (*eventpb.History, error) // Reset resets the internal state so next GetNextPage() call will return first page of events from beginning. Reset() // HasNextPage returns if there are more page of events diff --git a/internal/internal_task_handlers.go b/internal/internal_task_handlers.go index 73acdd869..dd6bba75a 100644 --- a/internal/internal_task_handlers.go +++ b/internal/internal_task_handlers.go @@ -35,9 +35,14 @@ import ( "time" "github.com/opentracing/opentracing-go" - commonproto "go.temporal.io/temporal-proto/common" - "go.temporal.io/temporal-proto/enums" + + commonpb "go.temporal.io/temporal-proto/common" + decisionpb "go.temporal.io/temporal-proto/decision" + eventpb "go.temporal.io/temporal-proto/event" + executionpb "go.temporal.io/temporal-proto/execution" + querypb "go.temporal.io/temporal-proto/query" "go.temporal.io/temporal-proto/serviceerror" + tasklistpb "go.temporal.io/temporal-proto/tasklist" "go.temporal.io/temporal-proto/workflowservice" "go.uber.org/zap" @@ -60,7 +65,7 @@ type ( workflowExecutionEventHandler interface { // Process a single event and return the assosciated decisions. // Return List of decisions made, any error. - ProcessEvent(event *commonproto.HistoryEvent, isReplay bool, isLast bool) error + ProcessEvent(event *eventpb.HistoryEvent, isReplay bool, isLast bool) error // ProcessQuery process a query request. ProcessQuery(queryType string, queryArgs []byte) ([]byte, error) StackTrace() string @@ -105,7 +110,7 @@ type ( previousStartedEventID int64 - newDecisions []*commonproto.Decision + newDecisions []*decisionpb.Decision currentDecisionTask *workflowservice.PollForDecisionTaskResponse laTunnel *localActivityTunnel decisionStartTime time.Time @@ -150,11 +155,11 @@ type ( history struct { workflowTask *workflowTask eventsHandler *workflowExecutionEventHandlerImpl - loadedEvents []*commonproto.HistoryEvent + loadedEvents []*eventpb.HistoryEvent currentIndex int nextEventID int64 // next expected eventID for sanity lastEventID int64 // last expected eventID, zero indicates read until end of stream - next []*commonproto.HistoryEvent + next []*eventpb.HistoryEvent binaryChecksum string } @@ -182,15 +187,15 @@ func (e decisionHeartbeatError) Error() string { } // Get workflow start event. -func (eh *history) GetWorkflowStartedEvent() (*commonproto.HistoryEvent, error) { +func (eh *history) GetWorkflowStartedEvent() (*eventpb.HistoryEvent, error) { events := eh.workflowTask.task.History.Events - if len(events) == 0 || events[0].GetEventType() != enums.EventTypeWorkflowExecutionStarted { + if len(events) == 0 || events[0].GetEventType() != eventpb.EventTypeWorkflowExecutionStarted { return nil, errors.New("unable to find WorkflowExecutionStartedEventAttributes in the history") } return events[0], nil } -func (eh *history) IsReplayEvent(event *commonproto.HistoryEvent) bool { +func (eh *history) IsReplayEvent(event *eventpb.HistoryEvent) bool { return event.GetEventId() <= eh.workflowTask.task.GetPreviousStartedEventId() || isDecisionEvent(event.GetEventType()) } @@ -206,9 +211,9 @@ func (eh *history) IsNextDecisionFailed() (isFailed bool, binaryChecksum string, if nextIndex < len(eh.loadedEvents) { nextEvent := eh.loadedEvents[nextIndex] nextEventType := nextEvent.GetEventType() - isFailed := nextEventType == enums.EventTypeDecisionTaskTimedOut || nextEventType == enums.EventTypeDecisionTaskFailed + isFailed := nextEventType == eventpb.EventTypeDecisionTaskTimedOut || nextEventType == eventpb.EventTypeDecisionTaskFailed var binaryChecksum string - if nextEventType == enums.EventTypeDecisionTaskCompleted { + if nextEventType == eventpb.EventTypeDecisionTaskCompleted { binaryChecksum = nextEvent.GetDecisionTaskCompletedEventAttributes().BinaryChecksum } return isFailed, binaryChecksum, nil @@ -228,22 +233,22 @@ func (eh *history) loadMoreEvents() error { return nil } -func isDecisionEvent(eventType enums.EventType) bool { +func isDecisionEvent(eventType eventpb.EventType) bool { switch eventType { - case enums.EventTypeWorkflowExecutionCompleted, - enums.EventTypeWorkflowExecutionFailed, - enums.EventTypeWorkflowExecutionCanceled, - enums.EventTypeWorkflowExecutionContinuedAsNew, - enums.EventTypeActivityTaskScheduled, - enums.EventTypeActivityTaskCancelRequested, - enums.EventTypeTimerStarted, - enums.EventTypeTimerCanceled, - enums.EventTypeCancelTimerFailed, - enums.EventTypeMarkerRecorded, - enums.EventTypeStartChildWorkflowExecutionInitiated, - enums.EventTypeRequestCancelExternalWorkflowExecutionInitiated, - enums.EventTypeSignalExternalWorkflowExecutionInitiated, - enums.EventTypeUpsertWorkflowSearchAttributes: + case eventpb.EventTypeWorkflowExecutionCompleted, + eventpb.EventTypeWorkflowExecutionFailed, + eventpb.EventTypeWorkflowExecutionCanceled, + eventpb.EventTypeWorkflowExecutionContinuedAsNew, + eventpb.EventTypeActivityTaskScheduled, + eventpb.EventTypeActivityTaskCancelRequested, + eventpb.EventTypeTimerStarted, + eventpb.EventTypeTimerCanceled, + eventpb.EventTypeCancelTimerFailed, + eventpb.EventTypeMarkerRecorded, + eventpb.EventTypeStartChildWorkflowExecutionInitiated, + eventpb.EventTypeRequestCancelExternalWorkflowExecutionInitiated, + eventpb.EventTypeSignalExternalWorkflowExecutionInitiated, + eventpb.EventTypeUpsertWorkflowSearchAttributes: return true default: return false @@ -252,7 +257,7 @@ func isDecisionEvent(eventType enums.EventType) bool { // NextDecisionEvents returns events that there processed as new by the next decision. // TODO(maxim): Refactor to return a struct instead of multiple parameters -func (eh *history) NextDecisionEvents() (result []*commonproto.HistoryEvent, markers []*commonproto.HistoryEvent, binaryChecksum string, err error) { +func (eh *history) NextDecisionEvents() (result []*eventpb.HistoryEvent, markers []*eventpb.HistoryEvent, binaryChecksum string, err error) { if eh.next == nil { eh.next, _, err = eh.nextDecisionEvents() if err != nil { @@ -273,7 +278,7 @@ func (eh *history) hasMoreEvents() bool { return historyIterator != nil && historyIterator.HasNextPage() } -func (eh *history) getMoreEvents() (*commonproto.History, error) { +func (eh *history) getMoreEvents() (*eventpb.History, error) { return eh.workflowTask.historyIterator.GetNextPage() } @@ -293,12 +298,12 @@ func (eh *history) verifyAllEventsProcessed() error { return nil } -func (eh *history) nextDecisionEvents() (nextEvents []*commonproto.HistoryEvent, markers []*commonproto.HistoryEvent, err error) { +func (eh *history) nextDecisionEvents() (nextEvents []*eventpb.HistoryEvent, markers []*eventpb.HistoryEvent, err error) { if eh.currentIndex == len(eh.loadedEvents) && !eh.hasMoreEvents() { if err := eh.verifyAllEventsProcessed(); err != nil { return nil, nil, err } - return []*commonproto.HistoryEvent{}, []*commonproto.HistoryEvent{}, nil + return []*eventpb.HistoryEvent{}, []*eventpb.HistoryEvent{}, nil } // Process events @@ -330,7 +335,7 @@ OrderEvents: eh.nextEventID++ switch event.GetEventType() { - case enums.EventTypeDecisionTaskStarted: + case eventpb.EventTypeDecisionTaskStarted: isFailed, binaryChecksum, err1 := eh.IsNextDecisionFailed() if err1 != nil { err = err1 @@ -342,9 +347,9 @@ OrderEvents: nextEvents = append(nextEvents, event) break OrderEvents } - case enums.EventTypeDecisionTaskScheduled, - enums.EventTypeDecisionTaskTimedOut, - enums.EventTypeDecisionTaskFailed: + case eventpb.EventTypeDecisionTaskScheduled, + eventpb.EventTypeDecisionTaskTimedOut, + eventpb.EventTypeDecisionTaskFailed: // Skip default: if isPreloadMarkerEvent(event) { @@ -362,8 +367,8 @@ OrderEvents: return nextEvents, markers, nil } -func isPreloadMarkerEvent(event *commonproto.HistoryEvent) bool { - return event.GetEventType() == enums.EventTypeMarkerRecorded +func isPreloadMarkerEvent(event *eventpb.HistoryEvent) bool { + return event.GetEventType() == eventpb.EventTypeMarkerRecorded } // newWorkflowTaskHandler returns an implementation of workflow task handler. @@ -527,7 +532,7 @@ func (w *workflowExecutionContextImpl) queueResetStickinessTask() { var task resetStickinessTask task.task = &workflowservice.ResetStickyTaskListRequest{ Namespace: w.workflowInfo.Namespace, - Execution: &commonproto.WorkflowExecution{ + Execution: &executionpb.WorkflowExecution{ WorkflowId: w.workflowInfo.WorkflowExecution.ID, RunId: w.workflowInfo.WorkflowExecution.RunID, }, @@ -572,7 +577,7 @@ func (w *workflowExecutionContextImpl) createEventHandler() { w.eventHandler.Store(eventHandler) } -func resetHistory(task *workflowservice.PollForDecisionTaskResponse, historyIterator HistoryIterator) (*commonproto.History, error) { +func resetHistory(task *workflowservice.PollForDecisionTaskResponse, historyIterator HistoryIterator) (*eventpb.History, error) { historyIterator.Reset() firstPageHistory, err := historyIterator.GetNextPage() if err != nil { @@ -690,8 +695,8 @@ func (wth *workflowTaskHandlerImpl) getOrCreateWorkflowContext( return } -func isFullHistory(history *commonproto.History) bool { - if len(history.Events) == 0 || history.Events[0].GetEventType() != enums.EventTypeWorkflowExecutionStarted { +func isFullHistory(history *eventpb.History) bool { + if len(history.Events) == 0 || history.Events[0].GetEventType() != eventpb.EventTypeWorkflowExecutionStarted { return false } return true @@ -723,8 +728,8 @@ func (wth *workflowTaskHandlerImpl) ProcessWorkflowTask( } task := workflowTask.task if task.History == nil || len(task.History.Events) == 0 { - task.History = &commonproto.History{ - Events: []*commonproto.HistoryEvent{}, + task.History = &eventpb.History{ + Events: []*eventpb.HistoryEvent{}, } } if task.Query == nil && len(task.History.Events) == 0 { @@ -806,8 +811,8 @@ func (w *workflowExecutionContextImpl) ProcessWorkflowTask(workflowTask *workflo eventHandler := w.getEventHandler() reorderedHistory := newHistory(workflowTask, eventHandler) - var replayDecisions []*commonproto.Decision - var respondEvents []*commonproto.HistoryEvent + var replayDecisions []*decisionpb.Decision + var respondEvents []*eventpb.HistoryEvent skipReplayCheck := w.skipReplayCheck() // Process events @@ -997,7 +1002,7 @@ func getRetryBackoff(lar *localActivityResult, now time.Time) time.Duration { var errReason string if len(p.NonRetriableErrorReasons) > 0 { if lar.err == ErrDeadlineExceeded { - errReason = "timeout:" + enums.TimeoutTypeScheduleToClose.String() + errReason = "timeout:" + eventpb.TimeoutTypeScheduleToClose.String() } else { errReason, _ = getErrorDetails(lar.err, nil) } @@ -1136,8 +1141,8 @@ func (w *workflowExecutionContextImpl) GetDecisionTimeout() time.Duration { return time.Second * time.Duration(w.workflowInfo.TaskStartToCloseTimeoutSeconds) } -func skipDeterministicCheckForDecision(d *commonproto.Decision) bool { - if d.GetDecisionType() == enums.DecisionTypeRecordMarker { +func skipDeterministicCheckForDecision(d *decisionpb.Decision) bool { + if d.GetDecisionType() == decisionpb.DecisionTypeRecordMarker { markerName := d.GetRecordMarkerDecisionAttributes().GetMarkerName() if markerName == versionMarkerName || markerName == mutableSideEffectMarkerName { return true @@ -1146,8 +1151,8 @@ func skipDeterministicCheckForDecision(d *commonproto.Decision) bool { return false } -func skipDeterministicCheckForEvent(e *commonproto.HistoryEvent) bool { - if e.GetEventType() == enums.EventTypeMarkerRecorded { +func skipDeterministicCheckForEvent(e *eventpb.HistoryEvent) bool { + if e.GetEventType() == eventpb.EventTypeMarkerRecorded { markerName := e.GetMarkerRecordedEventAttributes().GetMarkerName() if markerName == versionMarkerName || markerName == mutableSideEffectMarkerName { return true @@ -1157,12 +1162,12 @@ func skipDeterministicCheckForEvent(e *commonproto.HistoryEvent) bool { } // special check for upsert change version event -func skipDeterministicCheckForUpsertChangeVersion(events []*commonproto.HistoryEvent, idx int) bool { +func skipDeterministicCheckForUpsertChangeVersion(events []*eventpb.HistoryEvent, idx int) bool { e := events[idx] - if e.GetEventType() == enums.EventTypeMarkerRecorded && + if e.GetEventType() == eventpb.EventTypeMarkerRecorded && e.GetMarkerRecordedEventAttributes().GetMarkerName() == versionMarkerName && idx < len(events)-1 && - events[idx+1].GetEventType() == enums.EventTypeUpsertWorkflowSearchAttributes { + events[idx+1].GetEventType() == eventpb.EventTypeUpsertWorkflowSearchAttributes { if _, ok := events[idx+1].GetUpsertWorkflowSearchAttributesEventAttributes().SearchAttributes.IndexedFields[TemporalChangeVersion]; ok { return true } @@ -1170,14 +1175,14 @@ func skipDeterministicCheckForUpsertChangeVersion(events []*commonproto.HistoryE return false } -func matchReplayWithHistory(replayDecisions []*commonproto.Decision, historyEvents []*commonproto.HistoryEvent) error { +func matchReplayWithHistory(replayDecisions []*decisionpb.Decision, historyEvents []*eventpb.HistoryEvent) error { di := 0 hi := 0 hSize := len(historyEvents) dSize := len(replayDecisions) matchLoop: for hi < hSize || di < dSize { - var e *commonproto.HistoryEvent + var e *eventpb.HistoryEvent if hi < hSize { e = historyEvents[hi] if skipDeterministicCheckForUpsertChangeVersion(historyEvents, hi) { @@ -1190,7 +1195,7 @@ matchLoop: } } - var d *commonproto.Decision + var d *decisionpb.Decision if di < dSize { d = replayDecisions[di] if skipDeterministicCheckForDecision(d) { @@ -1226,10 +1231,10 @@ func lastPartOfName(name string) string { return name[lastDotIdx+1:] } -func isDecisionMatchEvent(d *commonproto.Decision, e *commonproto.HistoryEvent, strictMode bool) bool { +func isDecisionMatchEvent(d *decisionpb.Decision, e *eventpb.HistoryEvent, strictMode bool) bool { switch d.GetDecisionType() { - case enums.DecisionTypeScheduleActivityTask: - if e.GetEventType() != enums.EventTypeActivityTaskScheduled { + case decisionpb.DecisionTypeScheduleActivityTask: + if e.GetEventType() != eventpb.EventTypeActivityTaskScheduled { return false } eventAttributes := e.GetActivityTaskScheduledEventAttributes() @@ -1244,8 +1249,8 @@ func isDecisionMatchEvent(d *commonproto.Decision, e *commonproto.HistoryEvent, return true - case enums.DecisionTypeRequestCancelActivityTask: - if e.GetEventType() != enums.EventTypeActivityTaskCancelRequested { + case decisionpb.DecisionTypeRequestCancelActivityTask: + if e.GetEventType() != eventpb.EventTypeActivityTaskCancelRequested { return false } decisionAttributes := d.GetRequestCancelActivityTaskDecisionAttributes() @@ -1256,8 +1261,8 @@ func isDecisionMatchEvent(d *commonproto.Decision, e *commonproto.HistoryEvent, return true - case enums.DecisionTypeStartTimer: - if e.GetEventType() != enums.EventTypeTimerStarted { + case decisionpb.DecisionTypeStartTimer: + if e.GetEventType() != eventpb.EventTypeTimerStarted { return false } eventAttributes := e.GetTimerStartedEventAttributes() @@ -1270,17 +1275,17 @@ func isDecisionMatchEvent(d *commonproto.Decision, e *commonproto.HistoryEvent, return true - case enums.DecisionTypeCancelTimer: - if e.GetEventType() != enums.EventTypeTimerCanceled && e.GetEventType() != enums.EventTypeCancelTimerFailed { + case decisionpb.DecisionTypeCancelTimer: + if e.GetEventType() != eventpb.EventTypeTimerCanceled && e.GetEventType() != eventpb.EventTypeCancelTimerFailed { return false } decisionAttributes := d.GetCancelTimerDecisionAttributes() - if e.GetEventType() == enums.EventTypeTimerCanceled { + if e.GetEventType() == eventpb.EventTypeTimerCanceled { eventAttributes := e.GetTimerCanceledEventAttributes() if eventAttributes.GetTimerId() != decisionAttributes.GetTimerId() { return false } - } else if e.GetEventType() == enums.EventTypeCancelTimerFailed { + } else if e.GetEventType() == eventpb.EventTypeCancelTimerFailed { eventAttributes := e.GetCancelTimerFailedEventAttributes() if eventAttributes.GetTimerId() != decisionAttributes.GetTimerId() { return false @@ -1289,8 +1294,8 @@ func isDecisionMatchEvent(d *commonproto.Decision, e *commonproto.HistoryEvent, return true - case enums.DecisionTypeCompleteWorkflowExecution: - if e.GetEventType() != enums.EventTypeWorkflowExecutionCompleted { + case decisionpb.DecisionTypeCompleteWorkflowExecution: + if e.GetEventType() != eventpb.EventTypeWorkflowExecutionCompleted { return false } if strictMode { @@ -1304,8 +1309,8 @@ func isDecisionMatchEvent(d *commonproto.Decision, e *commonproto.HistoryEvent, return true - case enums.DecisionTypeFailWorkflowExecution: - if e.GetEventType() != enums.EventTypeWorkflowExecutionFailed { + case decisionpb.DecisionTypeFailWorkflowExecution: + if e.GetEventType() != eventpb.EventTypeWorkflowExecutionFailed { return false } if strictMode { @@ -1320,8 +1325,8 @@ func isDecisionMatchEvent(d *commonproto.Decision, e *commonproto.HistoryEvent, return true - case enums.DecisionTypeRecordMarker: - if e.GetEventType() != enums.EventTypeMarkerRecorded { + case decisionpb.DecisionTypeRecordMarker: + if e.GetEventType() != eventpb.EventTypeMarkerRecorded { return false } eventAttributes := e.GetMarkerRecordedEventAttributes() @@ -1332,8 +1337,8 @@ func isDecisionMatchEvent(d *commonproto.Decision, e *commonproto.HistoryEvent, return true - case enums.DecisionTypeRequestCancelExternalWorkflowExecution: - if e.GetEventType() != enums.EventTypeRequestCancelExternalWorkflowExecutionInitiated { + case decisionpb.DecisionTypeRequestCancelExternalWorkflowExecution: + if e.GetEventType() != eventpb.EventTypeRequestCancelExternalWorkflowExecutionInitiated { return false } eventAttributes := e.GetRequestCancelExternalWorkflowExecutionInitiatedEventAttributes() @@ -1345,8 +1350,8 @@ func isDecisionMatchEvent(d *commonproto.Decision, e *commonproto.HistoryEvent, return true - case enums.DecisionTypeSignalExternalWorkflowExecution: - if e.GetEventType() != enums.EventTypeSignalExternalWorkflowExecutionInitiated { + case decisionpb.DecisionTypeSignalExternalWorkflowExecution: + if e.GetEventType() != eventpb.EventTypeSignalExternalWorkflowExecutionInitiated { return false } eventAttributes := e.GetSignalExternalWorkflowExecutionInitiatedEventAttributes() @@ -1359,8 +1364,8 @@ func isDecisionMatchEvent(d *commonproto.Decision, e *commonproto.HistoryEvent, return true - case enums.DecisionTypeCancelWorkflowExecution: - if e.GetEventType() != enums.EventTypeWorkflowExecutionCanceled { + case decisionpb.DecisionTypeCancelWorkflowExecution: + if e.GetEventType() != eventpb.EventTypeWorkflowExecutionCanceled { return false } if strictMode { @@ -1372,15 +1377,15 @@ func isDecisionMatchEvent(d *commonproto.Decision, e *commonproto.HistoryEvent, } return true - case enums.DecisionTypeContinueAsNewWorkflowExecution: - if e.GetEventType() != enums.EventTypeWorkflowExecutionContinuedAsNew { + case decisionpb.DecisionTypeContinueAsNewWorkflowExecution: + if e.GetEventType() != eventpb.EventTypeWorkflowExecutionContinuedAsNew { return false } return true - case enums.DecisionTypeStartChildWorkflowExecution: - if e.GetEventType() != enums.EventTypeStartChildWorkflowExecutionInitiated { + case decisionpb.DecisionTypeStartChildWorkflowExecution: + if e.GetEventType() != eventpb.EventTypeStartChildWorkflowExecutionInitiated { return false } eventAttributes := e.GetStartChildWorkflowExecutionInitiatedEventAttributes() @@ -1393,8 +1398,8 @@ func isDecisionMatchEvent(d *commonproto.Decision, e *commonproto.HistoryEvent, return true - case enums.DecisionTypeUpsertWorkflowSearchAttributes: - if e.GetEventType() != enums.EventTypeUpsertWorkflowSearchAttributes { + case decisionpb.DecisionTypeUpsertWorkflowSearchAttributes: + if e.GetEventType() != eventpb.EventTypeUpsertWorkflowSearchAttributes { return false } eventAttributes := e.GetUpsertWorkflowSearchAttributesEventAttributes() @@ -1408,7 +1413,7 @@ func isDecisionMatchEvent(d *commonproto.Decision, e *commonproto.HistoryEvent, return false } -func isSearchAttributesMatched(attrFromEvent, attrFromDecision *commonproto.SearchAttributes) bool { +func isSearchAttributesMatched(attrFromEvent, attrFromDecision *commonpb.SearchAttributes) bool { if attrFromEvent != nil && attrFromDecision != nil { return reflect.DeepEqual(attrFromEvent.IndexedFields, attrFromDecision.IndexedFields) } @@ -1430,24 +1435,24 @@ func (wth *workflowTaskHandlerImpl) completeWorkflow( eventHandler *workflowExecutionEventHandlerImpl, task *workflowservice.PollForDecisionTaskResponse, workflowContext *workflowExecutionContextImpl, - decisions []*commonproto.Decision, + decisions []*decisionpb.Decision, forceNewDecision bool) interface{} { // for query task if task.Query != nil { queryCompletedRequest := &workflowservice.RespondQueryTaskCompletedRequest{TaskToken: task.TaskToken} if panicErr, ok := workflowContext.err.(*PanicError); ok { - queryCompletedRequest.CompletedType = enums.QueryTaskCompletedTypeFailed + queryCompletedRequest.CompletedType = querypb.QueryTaskCompletedTypeFailed queryCompletedRequest.ErrorMessage = "Workflow panic: " + panicErr.Error() return queryCompletedRequest } result, err := eventHandler.ProcessQuery(task.Query.GetQueryType(), task.Query.QueryArgs) if err != nil { - queryCompletedRequest.CompletedType = enums.QueryTaskCompletedTypeFailed + queryCompletedRequest.CompletedType = querypb.QueryTaskCompletedTypeFailed queryCompletedRequest.ErrorMessage = err.Error() } else { - queryCompletedRequest.CompletedType = enums.QueryTaskCompletedTypeCompleted + queryCompletedRequest.CompletedType = querypb.QueryTaskCompletedTypeCompleted queryCompletedRequest.QueryResult = result } return queryCompletedRequest @@ -1468,23 +1473,23 @@ func (wth *workflowTaskHandlerImpl) completeWorkflow( } // complete decision task - var closeDecision *commonproto.Decision + var closeDecision *decisionpb.Decision if canceledErr, ok := workflowContext.err.(*CanceledError); ok { // Workflow cancelled metricsScope.Counter(metrics.WorkflowCanceledCounter).Inc(1) - closeDecision = createNewDecision(enums.DecisionTypeCancelWorkflowExecution) + closeDecision = createNewDecision(decisionpb.DecisionTypeCancelWorkflowExecution) _, details := getErrorDetails(canceledErr, wth.dataConverter) - closeDecision.Attributes = &commonproto.Decision_CancelWorkflowExecutionDecisionAttributes{CancelWorkflowExecutionDecisionAttributes: &commonproto.CancelWorkflowExecutionDecisionAttributes{ + closeDecision.Attributes = &decisionpb.Decision_CancelWorkflowExecutionDecisionAttributes{CancelWorkflowExecutionDecisionAttributes: &decisionpb.CancelWorkflowExecutionDecisionAttributes{ Details: details, }} } else if contErr, ok := workflowContext.err.(*ContinueAsNewError); ok { // Continue as new error. metricsScope.Counter(metrics.WorkflowContinueAsNewCounter).Inc(1) - closeDecision = createNewDecision(enums.DecisionTypeContinueAsNewWorkflowExecution) - closeDecision.Attributes = &commonproto.Decision_ContinueAsNewWorkflowExecutionDecisionAttributes{ContinueAsNewWorkflowExecutionDecisionAttributes: &commonproto.ContinueAsNewWorkflowExecutionDecisionAttributes{ - WorkflowType: &commonproto.WorkflowType{Name: contErr.params.workflowType.Name}, + closeDecision = createNewDecision(decisionpb.DecisionTypeContinueAsNewWorkflowExecution) + closeDecision.Attributes = &decisionpb.Decision_ContinueAsNewWorkflowExecutionDecisionAttributes{ContinueAsNewWorkflowExecutionDecisionAttributes: &decisionpb.ContinueAsNewWorkflowExecutionDecisionAttributes{ + WorkflowType: &commonpb.WorkflowType{Name: contErr.params.workflowType.Name}, Input: contErr.params.input, - TaskList: &commonproto.TaskList{Name: contErr.params.taskListName}, + TaskList: &tasklistpb.TaskList{Name: contErr.params.taskListName}, ExecutionStartToCloseTimeoutSeconds: contErr.params.executionStartToCloseTimeoutSeconds, TaskStartToCloseTimeoutSeconds: contErr.params.taskStartToCloseTimeoutSeconds, Header: contErr.params.header, @@ -1494,17 +1499,17 @@ func (wth *workflowTaskHandlerImpl) completeWorkflow( } else if workflowContext.err != nil { // Workflow failures metricsScope.Counter(metrics.WorkflowFailedCounter).Inc(1) - closeDecision = createNewDecision(enums.DecisionTypeFailWorkflowExecution) + closeDecision = createNewDecision(decisionpb.DecisionTypeFailWorkflowExecution) reason, details := getErrorDetails(workflowContext.err, wth.dataConverter) - closeDecision.Attributes = &commonproto.Decision_FailWorkflowExecutionDecisionAttributes{FailWorkflowExecutionDecisionAttributes: &commonproto.FailWorkflowExecutionDecisionAttributes{ + closeDecision.Attributes = &decisionpb.Decision_FailWorkflowExecutionDecisionAttributes{FailWorkflowExecutionDecisionAttributes: &decisionpb.FailWorkflowExecutionDecisionAttributes{ Reason: reason, Details: details, }} } else if workflowContext.isWorkflowCompleted { // Workflow completion metricsScope.Counter(metrics.WorkflowCompletedCounter).Inc(1) - closeDecision = createNewDecision(enums.DecisionTypeCompleteWorkflowExecution) - closeDecision.Attributes = &commonproto.Decision_CompleteWorkflowExecutionDecisionAttributes{CompleteWorkflowExecutionDecisionAttributes: &commonproto.CompleteWorkflowExecutionDecisionAttributes{ + closeDecision = createNewDecision(decisionpb.DecisionTypeCompleteWorkflowExecution) + closeDecision.Attributes = &decisionpb.Decision_CompleteWorkflowExecutionDecisionAttributes{CompleteWorkflowExecutionDecisionAttributes: &decisionpb.CompleteWorkflowExecutionDecisionAttributes{ Result: workflowContext.result, }} } @@ -1516,19 +1521,19 @@ func (wth *workflowTaskHandlerImpl) completeWorkflow( forceNewDecision = false } - var queryResults map[string]*commonproto.WorkflowQueryResult + var queryResults map[string]*querypb.WorkflowQueryResult if len(task.Queries) != 0 { - queryResults = make(map[string]*commonproto.WorkflowQueryResult) + queryResults = make(map[string]*querypb.WorkflowQueryResult) for queryID, query := range task.Queries { result, err := eventHandler.ProcessQuery(query.GetQueryType(), query.QueryArgs) if err != nil { - queryResults[queryID] = &commonproto.WorkflowQueryResult{ - ResultType: enums.QueryResultTypeFailed, + queryResults[queryID] = &querypb.WorkflowQueryResult{ + ResultType: querypb.QueryResultTypeFailed, ErrorMessage: err.Error(), } } else { - queryResults[queryID] = &commonproto.WorkflowQueryResult{ - ResultType: enums.QueryResultTypeAnswered, + queryResults[queryID] = &querypb.WorkflowQueryResult{ + ResultType: querypb.QueryResultTypeAnswered, Answer: result, } } @@ -1550,23 +1555,23 @@ func errorToFailDecisionTask(taskToken []byte, err error, identity string) *work _, details := getErrorDetails(err, nil) return &workflowservice.RespondDecisionTaskFailedRequest{ TaskToken: taskToken, - Cause: enums.DecisionTaskFailedCauseWorkflowWorkerUnhandledFailure, + Cause: eventpb.DecisionTaskFailedCauseWorkflowWorkerUnhandledFailure, Details: details, Identity: identity, BinaryChecksum: getBinaryChecksum(), } } -func (wth *workflowTaskHandlerImpl) executeAnyPressurePoints(event *commonproto.HistoryEvent, isInReplay bool) error { +func (wth *workflowTaskHandlerImpl) executeAnyPressurePoints(event *eventpb.HistoryEvent, isInReplay bool) error { if wth.ppMgr != nil && !reflect.ValueOf(wth.ppMgr).IsNil() && !isInReplay { switch event.GetEventType() { - case enums.EventTypeDecisionTaskStarted: + case eventpb.EventTypeDecisionTaskStarted: return wth.ppMgr.Execute(pressurePointTypeDecisionTaskStartTimeout) - case enums.EventTypeActivityTaskScheduled: + case eventpb.EventTypeActivityTaskScheduled: return wth.ppMgr.Execute(pressurePointTypeActivityTaskScheduleTimeout) - case enums.EventTypeActivityTaskStarted: + case eventpb.EventTypeActivityTaskStarted: return wth.ppMgr.Execute(pressurePointTypeActivityTaskStartTimeout) - case enums.EventTypeDecisionTaskCompleted: + case eventpb.EventTypeDecisionTaskCompleted: return wth.ppMgr.Execute(pressurePointTypeDecisionTaskCompleted) } } @@ -1838,8 +1843,8 @@ func (ath *activityTaskHandlerImpl) getRegisteredActivityNames() (activityNames return } -func createNewDecision(decisionType enums.DecisionType) *commonproto.Decision { - return &commonproto.Decision{ +func createNewDecision(decisionType decisionpb.DecisionType) *decisionpb.Decision { + return &decisionpb.Decision{ DecisionType: decisionType, } } diff --git a/internal/internal_task_handlers_interfaces_test.go b/internal/internal_task_handlers_interfaces_test.go index 76d707404..744f67619 100644 --- a/internal/internal_task_handlers_interfaces_test.go +++ b/internal/internal_task_handlers_interfaces_test.go @@ -27,8 +27,8 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" - commonproto "go.temporal.io/temporal-proto/common" - "go.temporal.io/temporal-proto/enums" + eventpb "go.temporal.io/temporal-proto/event" + tasklistpb "go.temporal.io/temporal-proto/tasklist" "go.temporal.io/temporal-proto/workflowservice" "go.temporal.io/temporal-proto/workflowservicemock" ) @@ -143,26 +143,26 @@ func (s *PollLayerInterfacesTestSuite) TestProcessActivityTaskInterface() { func (s *PollLayerInterfacesTestSuite) TestGetNextDecisions() { // Schedule an activity and see if we complete workflow. taskList := "tl1" - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(3), { EventId: 4, - EventType: enums.EventTypeDecisionTaskFailed, + EventType: eventpb.EventTypeDecisionTaskFailed, }, { EventId: 5, - EventType: enums.EventTypeWorkflowExecutionSignaled, + EventType: eventpb.EventTypeWorkflowExecutionSignaled, }, - createTestEventDecisionTaskScheduled(6, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(6, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(7), } task := createWorkflowTask(testEvents[0:3], 0, "HelloWorld_Workflow") historyIterator := &historyIteratorImpl{ - iteratorFunc: func(nextToken []byte) (*commonproto.History, []byte, error) { - return &commonproto.History{ + iteratorFunc: func(nextToken []byte) (*eventpb.History, []byte, error) { + return &eventpb.History{ Events: testEvents[3:], }, nil, nil }, @@ -177,7 +177,7 @@ func (s *PollLayerInterfacesTestSuite) TestGetNextDecisions() { s.NoError(err) s.Equal(3, len(events)) - s.Equal(enums.EventTypeWorkflowExecutionSignaled, events[1].GetEventType()) - s.Equal(enums.EventTypeDecisionTaskStarted, events[2].GetEventType()) + s.Equal(eventpb.EventTypeWorkflowExecutionSignaled, events[1].GetEventType()) + s.Equal(eventpb.EventTypeDecisionTaskStarted, events[2].GetEventType()) s.Equal(int64(7), events[2].GetEventId()) } diff --git a/internal/internal_task_handlers_test.go b/internal/internal_task_handlers_test.go index 98a696e66..7f2955798 100644 --- a/internal/internal_task_handlers_test.go +++ b/internal/internal_task_handlers_test.go @@ -34,11 +34,15 @@ import ( "github.com/pborman/uuid" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + commonpb "go.temporal.io/temporal-proto/common" + decisionpb "go.temporal.io/temporal-proto/decision" + eventpb "go.temporal.io/temporal-proto/event" + executionpb "go.temporal.io/temporal-proto/execution" + querypb "go.temporal.io/temporal-proto/query" "go.temporal.io/temporal-proto/serviceerror" + tasklistpb "go.temporal.io/temporal-proto/tasklist" "go.uber.org/zap" - commonproto "go.temporal.io/temporal-proto/common" - "go.temporal.io/temporal-proto/enums" "go.temporal.io/temporal-proto/workflowservice" "go.temporal.io/temporal-proto/workflowservicemock" ) @@ -128,77 +132,77 @@ func TestTaskHandlersTestSuite(t *testing.T) { }) } -func createTestEventWorkflowExecutionCompleted(eventID int64, attr *commonproto.WorkflowExecutionCompletedEventAttributes) *commonproto.HistoryEvent { - return &commonproto.HistoryEvent{ +func createTestEventWorkflowExecutionCompleted(eventID int64, attr *eventpb.WorkflowExecutionCompletedEventAttributes) *eventpb.HistoryEvent { + return &eventpb.HistoryEvent{ EventId: eventID, - EventType: enums.EventTypeWorkflowExecutionCompleted, - Attributes: &commonproto.HistoryEvent_WorkflowExecutionCompletedEventAttributes{WorkflowExecutionCompletedEventAttributes: attr}} + EventType: eventpb.EventTypeWorkflowExecutionCompleted, + Attributes: &eventpb.HistoryEvent_WorkflowExecutionCompletedEventAttributes{WorkflowExecutionCompletedEventAttributes: attr}} } -func createTestEventWorkflowExecutionStarted(eventID int64, attr *commonproto.WorkflowExecutionStartedEventAttributes) *commonproto.HistoryEvent { - return &commonproto.HistoryEvent{ +func createTestEventWorkflowExecutionStarted(eventID int64, attr *eventpb.WorkflowExecutionStartedEventAttributes) *eventpb.HistoryEvent { + return &eventpb.HistoryEvent{ EventId: eventID, - EventType: enums.EventTypeWorkflowExecutionStarted, - Attributes: &commonproto.HistoryEvent_WorkflowExecutionStartedEventAttributes{WorkflowExecutionStartedEventAttributes: attr}} + EventType: eventpb.EventTypeWorkflowExecutionStarted, + Attributes: &eventpb.HistoryEvent_WorkflowExecutionStartedEventAttributes{WorkflowExecutionStartedEventAttributes: attr}} } -func createTestEventLocalActivity(eventID int64, attr *commonproto.MarkerRecordedEventAttributes) *commonproto.HistoryEvent { - return &commonproto.HistoryEvent{ +func createTestEventLocalActivity(eventID int64, attr *eventpb.MarkerRecordedEventAttributes) *eventpb.HistoryEvent { + return &eventpb.HistoryEvent{ EventId: eventID, - EventType: enums.EventTypeMarkerRecorded, - Attributes: &commonproto.HistoryEvent_MarkerRecordedEventAttributes{MarkerRecordedEventAttributes: attr}} + EventType: eventpb.EventTypeMarkerRecorded, + Attributes: &eventpb.HistoryEvent_MarkerRecordedEventAttributes{MarkerRecordedEventAttributes: attr}} } -func createTestEventActivityTaskScheduled(eventID int64, attr *commonproto.ActivityTaskScheduledEventAttributes) *commonproto.HistoryEvent { - return &commonproto.HistoryEvent{ +func createTestEventActivityTaskScheduled(eventID int64, attr *eventpb.ActivityTaskScheduledEventAttributes) *eventpb.HistoryEvent { + return &eventpb.HistoryEvent{ EventId: eventID, - EventType: enums.EventTypeActivityTaskScheduled, - Attributes: &commonproto.HistoryEvent_ActivityTaskScheduledEventAttributes{ActivityTaskScheduledEventAttributes: attr}} + EventType: eventpb.EventTypeActivityTaskScheduled, + Attributes: &eventpb.HistoryEvent_ActivityTaskScheduledEventAttributes{ActivityTaskScheduledEventAttributes: attr}} } -func createTestEventActivityTaskStarted(eventID int64, attr *commonproto.ActivityTaskStartedEventAttributes) *commonproto.HistoryEvent { - return &commonproto.HistoryEvent{ +func createTestEventActivityTaskStarted(eventID int64, attr *eventpb.ActivityTaskStartedEventAttributes) *eventpb.HistoryEvent { + return &eventpb.HistoryEvent{ EventId: eventID, - EventType: enums.EventTypeActivityTaskStarted, - Attributes: &commonproto.HistoryEvent_ActivityTaskStartedEventAttributes{ActivityTaskStartedEventAttributes: attr}} + EventType: eventpb.EventTypeActivityTaskStarted, + Attributes: &eventpb.HistoryEvent_ActivityTaskStartedEventAttributes{ActivityTaskStartedEventAttributes: attr}} } -func createTestEventActivityTaskCompleted(eventID int64, attr *commonproto.ActivityTaskCompletedEventAttributes) *commonproto.HistoryEvent { - return &commonproto.HistoryEvent{ +func createTestEventActivityTaskCompleted(eventID int64, attr *eventpb.ActivityTaskCompletedEventAttributes) *eventpb.HistoryEvent { + return &eventpb.HistoryEvent{ EventId: eventID, - EventType: enums.EventTypeActivityTaskCompleted, - Attributes: &commonproto.HistoryEvent_ActivityTaskCompletedEventAttributes{ActivityTaskCompletedEventAttributes: attr}} + EventType: eventpb.EventTypeActivityTaskCompleted, + Attributes: &eventpb.HistoryEvent_ActivityTaskCompletedEventAttributes{ActivityTaskCompletedEventAttributes: attr}} } -func createTestEventActivityTaskTimedOut(eventID int64, attr *commonproto.ActivityTaskTimedOutEventAttributes) *commonproto.HistoryEvent { - return &commonproto.HistoryEvent{ +func createTestEventActivityTaskTimedOut(eventID int64, attr *eventpb.ActivityTaskTimedOutEventAttributes) *eventpb.HistoryEvent { + return &eventpb.HistoryEvent{ EventId: eventID, - EventType: enums.EventTypeActivityTaskTimedOut, - Attributes: &commonproto.HistoryEvent_ActivityTaskTimedOutEventAttributes{ActivityTaskTimedOutEventAttributes: attr}} + EventType: eventpb.EventTypeActivityTaskTimedOut, + Attributes: &eventpb.HistoryEvent_ActivityTaskTimedOutEventAttributes{ActivityTaskTimedOutEventAttributes: attr}} } -func createTestEventDecisionTaskScheduled(eventID int64, attr *commonproto.DecisionTaskScheduledEventAttributes) *commonproto.HistoryEvent { - return &commonproto.HistoryEvent{ +func createTestEventDecisionTaskScheduled(eventID int64, attr *eventpb.DecisionTaskScheduledEventAttributes) *eventpb.HistoryEvent { + return &eventpb.HistoryEvent{ EventId: eventID, - EventType: enums.EventTypeDecisionTaskScheduled, - Attributes: &commonproto.HistoryEvent_DecisionTaskScheduledEventAttributes{DecisionTaskScheduledEventAttributes: attr}} + EventType: eventpb.EventTypeDecisionTaskScheduled, + Attributes: &eventpb.HistoryEvent_DecisionTaskScheduledEventAttributes{DecisionTaskScheduledEventAttributes: attr}} } -func createTestEventDecisionTaskStarted(eventID int64) *commonproto.HistoryEvent { - return &commonproto.HistoryEvent{ +func createTestEventDecisionTaskStarted(eventID int64) *eventpb.HistoryEvent { + return &eventpb.HistoryEvent{ EventId: eventID, - EventType: enums.EventTypeDecisionTaskStarted} + EventType: eventpb.EventTypeDecisionTaskStarted} } -func createTestEventWorkflowExecutionSignaled(eventID int64, signalName string) *commonproto.HistoryEvent { +func createTestEventWorkflowExecutionSignaled(eventID int64, signalName string) *eventpb.HistoryEvent { return createTestEventWorkflowExecutionSignaledWithPayload(eventID, signalName, nil) } -func createTestEventWorkflowExecutionSignaledWithPayload(eventID int64, signalName string, payload []byte) *commonproto.HistoryEvent { - return &commonproto.HistoryEvent{ +func createTestEventWorkflowExecutionSignaledWithPayload(eventID int64, signalName string, payload []byte) *eventpb.HistoryEvent { + return &eventpb.HistoryEvent{ EventId: eventID, - EventType: enums.EventTypeWorkflowExecutionSignaled, - Attributes: &commonproto.HistoryEvent_WorkflowExecutionSignaledEventAttributes{WorkflowExecutionSignaledEventAttributes: &commonproto.WorkflowExecutionSignaledEventAttributes{ + EventType: eventpb.EventTypeWorkflowExecutionSignaled, + Attributes: &eventpb.HistoryEvent_WorkflowExecutionSignaledEventAttributes{WorkflowExecutionSignaledEventAttributes: &eventpb.WorkflowExecutionSignaledEventAttributes{ SignalName: signalName, Input: payload, Identity: "test-identity", @@ -206,29 +210,29 @@ func createTestEventWorkflowExecutionSignaledWithPayload(eventID int64, signalNa } } -func createTestEventDecisionTaskCompleted(eventID int64, attr *commonproto.DecisionTaskCompletedEventAttributes) *commonproto.HistoryEvent { - return &commonproto.HistoryEvent{ +func createTestEventDecisionTaskCompleted(eventID int64, attr *eventpb.DecisionTaskCompletedEventAttributes) *eventpb.HistoryEvent { + return &eventpb.HistoryEvent{ EventId: eventID, - EventType: enums.EventTypeDecisionTaskCompleted, - Attributes: &commonproto.HistoryEvent_DecisionTaskCompletedEventAttributes{DecisionTaskCompletedEventAttributes: attr}} + EventType: eventpb.EventTypeDecisionTaskCompleted, + Attributes: &eventpb.HistoryEvent_DecisionTaskCompletedEventAttributes{DecisionTaskCompletedEventAttributes: attr}} } -func createTestEventDecisionTaskFailed(eventID int64, attr *commonproto.DecisionTaskFailedEventAttributes) *commonproto.HistoryEvent { - return &commonproto.HistoryEvent{ +func createTestEventDecisionTaskFailed(eventID int64, attr *eventpb.DecisionTaskFailedEventAttributes) *eventpb.HistoryEvent { + return &eventpb.HistoryEvent{ EventId: eventID, - EventType: enums.EventTypeDecisionTaskFailed, - Attributes: &commonproto.HistoryEvent_DecisionTaskFailedEventAttributes{DecisionTaskFailedEventAttributes: attr}} + EventType: eventpb.EventTypeDecisionTaskFailed, + Attributes: &eventpb.HistoryEvent_DecisionTaskFailedEventAttributes{DecisionTaskFailedEventAttributes: attr}} } -func createTestEventSignalExternalWorkflowExecutionFailed(eventID int64, attr *commonproto.SignalExternalWorkflowExecutionFailedEventAttributes) *commonproto.HistoryEvent { - return &commonproto.HistoryEvent{ +func createTestEventSignalExternalWorkflowExecutionFailed(eventID int64, attr *eventpb.SignalExternalWorkflowExecutionFailedEventAttributes) *eventpb.HistoryEvent { + return &eventpb.HistoryEvent{ EventId: eventID, - EventType: enums.EventTypeSignalExternalWorkflowExecutionFailed, - Attributes: &commonproto.HistoryEvent_SignalExternalWorkflowExecutionFailedEventAttributes{SignalExternalWorkflowExecutionFailedEventAttributes: attr}} + EventType: eventpb.EventTypeSignalExternalWorkflowExecutionFailed, + Attributes: &eventpb.HistoryEvent_SignalExternalWorkflowExecutionFailedEventAttributes{SignalExternalWorkflowExecutionFailedEventAttributes: attr}} } func createWorkflowTask( - events []*commonproto.HistoryEvent, + events []*eventpb.HistoryEvent, previousStartEventID int64, workflowName string, ) *workflowservice.PollForDecisionTaskResponse { @@ -236,18 +240,18 @@ func createWorkflowTask( } func createWorkflowTaskWithQueries( - events []*commonproto.HistoryEvent, + events []*eventpb.HistoryEvent, previousStartEventID int64, workflowName string, - queries map[string]*commonproto.WorkflowQuery, + queries map[string]*querypb.WorkflowQuery, ) *workflowservice.PollForDecisionTaskResponse { - eventsCopy := make([]*commonproto.HistoryEvent, len(events)) + eventsCopy := make([]*eventpb.HistoryEvent, len(events)) copy(eventsCopy, events) return &workflowservice.PollForDecisionTaskResponse{ PreviousStartedEventId: previousStartEventID, - WorkflowType: &commonproto.WorkflowType{Name: workflowName}, - History: &commonproto.History{Events: eventsCopy}, - WorkflowExecution: &commonproto.WorkflowExecution{ + WorkflowType: &commonpb.WorkflowType{Name: workflowName}, + History: &eventpb.History{Events: eventsCopy}, + WorkflowExecution: &executionpb.WorkflowExecution{ WorkflowId: "fake-workflow-id", RunId: uuid.New(), }, @@ -256,48 +260,48 @@ func createWorkflowTaskWithQueries( } func createQueryTask( - events []*commonproto.HistoryEvent, + events []*eventpb.HistoryEvent, previousStartEventID int64, workflowName string, queryType string, ) *workflowservice.PollForDecisionTaskResponse { task := createWorkflowTask(events, previousStartEventID, workflowName) - task.Query = &commonproto.WorkflowQuery{ + task.Query = &querypb.WorkflowQuery{ QueryType: queryType, } return task } -func createTestEventTimerStarted(eventID int64, id int) *commonproto.HistoryEvent { +func createTestEventTimerStarted(eventID int64, id int) *eventpb.HistoryEvent { timerID := fmt.Sprintf("%v", id) - attr := &commonproto.TimerStartedEventAttributes{ + attr := &eventpb.TimerStartedEventAttributes{ TimerId: timerID, StartToFireTimeoutSeconds: 0, DecisionTaskCompletedEventId: 0, } - return &commonproto.HistoryEvent{ + return &eventpb.HistoryEvent{ EventId: eventID, - EventType: enums.EventTypeTimerStarted, - Attributes: &commonproto.HistoryEvent_TimerStartedEventAttributes{TimerStartedEventAttributes: attr}} + EventType: eventpb.EventTypeTimerStarted, + Attributes: &eventpb.HistoryEvent_TimerStartedEventAttributes{TimerStartedEventAttributes: attr}} } -func createTestEventTimerFired(eventID int64, id int) *commonproto.HistoryEvent { +func createTestEventTimerFired(eventID int64, id int) *eventpb.HistoryEvent { timerID := fmt.Sprintf("%v", id) - attr := &commonproto.TimerFiredEventAttributes{ + attr := &eventpb.TimerFiredEventAttributes{ TimerId: timerID, } - return &commonproto.HistoryEvent{ + return &eventpb.HistoryEvent{ EventId: eventID, - EventType: enums.EventTypeTimerFired, - Attributes: &commonproto.HistoryEvent_TimerFiredEventAttributes{TimerFiredEventAttributes: attr}} + EventType: eventpb.EventTypeTimerFired, + Attributes: &eventpb.HistoryEvent_TimerFiredEventAttributes{TimerFiredEventAttributes: attr}} } var testWorkflowTaskTasklist = "tl1" func (t *TaskHandlersTestSuite) testWorkflowTaskWorkflowExecutionStartedHelper(params workerExecutionParameters) { - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{TaskList: &commonproto.TaskList{Name: testWorkflowTaskTasklist}}), + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{TaskList: &tasklistpb.TaskList{Name: testWorkflowTaskTasklist}}), } task := createWorkflowTask(testEvents, 0, "HelloWorld_Workflow") taskHandler := newWorkflowTaskHandler(params, nil, t.registry) @@ -306,7 +310,7 @@ func (t *TaskHandlersTestSuite) testWorkflowTaskWorkflowExecutionStartedHelper(p t.NoError(err) t.NotNil(response) t.Equal(1, len(response.Decisions)) - t.Equal(enums.DecisionTypeScheduleActivityTask, response.Decisions[0].GetDecisionType()) + t.Equal(decisionpb.DecisionTypeScheduleActivityTask, response.Decisions[0].GetDecisionType()) t.NotNil(response.Decisions[0].GetScheduleActivityTaskDecisionAttributes()) } @@ -333,19 +337,19 @@ func (t *TaskHandlersTestSuite) TestWorkflowTask_BinaryChecksum() { taskList := "tl1" checksum1 := "chck1" checksum2 := "chck2" - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(3), - createTestEventDecisionTaskCompleted(4, &commonproto.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2, BinaryChecksum: checksum1}), + createTestEventDecisionTaskCompleted(4, &eventpb.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2, BinaryChecksum: checksum1}), createTestEventTimerStarted(5, 0), createTestEventTimerFired(6, 0), - createTestEventDecisionTaskScheduled(7, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(7, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(8), - createTestEventDecisionTaskCompleted(9, &commonproto.DecisionTaskCompletedEventAttributes{ScheduledEventId: 7, BinaryChecksum: checksum2}), + createTestEventDecisionTaskCompleted(9, &eventpb.DecisionTaskCompletedEventAttributes{ScheduledEventId: 7, BinaryChecksum: checksum2}), createTestEventTimerStarted(10, 1), createTestEventTimerFired(11, 1), - createTestEventDecisionTaskScheduled(12, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(12, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(13), } task := createWorkflowTask(testEvents, 8, "BinaryChecksumWorkflow") @@ -362,7 +366,7 @@ func (t *TaskHandlersTestSuite) TestWorkflowTask_BinaryChecksum() { t.NoError(err) t.NotNil(response) t.Equal(1, len(response.Decisions)) - t.Equal(enums.DecisionTypeCompleteWorkflowExecution, response.Decisions[0].GetDecisionType()) + t.Equal(decisionpb.DecisionTypeCompleteWorkflowExecution, response.Decisions[0].GetDecisionType()) checksumsJSON := string(response.Decisions[0].GetCompleteWorkflowExecutionDecisionAttributes().Result) var checksums []string _ = json.Unmarshal([]byte(checksumsJSON), &checksums) @@ -375,18 +379,18 @@ func (t *TaskHandlersTestSuite) TestWorkflowTask_BinaryChecksum() { func (t *TaskHandlersTestSuite) TestWorkflowTask_ActivityTaskScheduled() { // Schedule an activity and see if we complete workflow. taskList := "tl1" - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(3), - createTestEventDecisionTaskCompleted(4, &commonproto.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2}), - createTestEventActivityTaskScheduled(5, &commonproto.ActivityTaskScheduledEventAttributes{ + createTestEventDecisionTaskCompleted(4, &eventpb.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2}), + createTestEventActivityTaskScheduled(5, &eventpb.ActivityTaskScheduledEventAttributes{ ActivityId: "0", - ActivityType: &commonproto.ActivityType{Name: "Greeter_Activity"}, - TaskList: &commonproto.TaskList{Name: taskList}, + ActivityType: &commonpb.ActivityType{Name: "Greeter_Activity"}, + TaskList: &tasklistpb.TaskList{Name: taskList}, }), - createTestEventActivityTaskStarted(6, &commonproto.ActivityTaskStartedEventAttributes{}), - createTestEventActivityTaskCompleted(7, &commonproto.ActivityTaskCompletedEventAttributes{ScheduledEventId: 5}), + createTestEventActivityTaskStarted(6, &eventpb.ActivityTaskStartedEventAttributes{}), + createTestEventActivityTaskCompleted(7, &eventpb.ActivityTaskCompletedEventAttributes{ScheduledEventId: 5}), createTestEventDecisionTaskStarted(8), } task := createWorkflowTask(testEvents[0:3], 0, "HelloWorld_Workflow") @@ -403,7 +407,7 @@ func (t *TaskHandlersTestSuite) TestWorkflowTask_ActivityTaskScheduled() { t.NoError(err) t.NotNil(response) t.Equal(1, len(response.Decisions)) - t.Equal(enums.DecisionTypeScheduleActivityTask, response.Decisions[0].GetDecisionType()) + t.Equal(decisionpb.DecisionTypeScheduleActivityTask, response.Decisions[0].GetDecisionType()) t.NotNil(response.Decisions[0].GetScheduleActivityTaskDecisionAttributes()) // Schedule an activity and see if we complete workflow, Having only one last decision. @@ -413,29 +417,29 @@ func (t *TaskHandlersTestSuite) TestWorkflowTask_ActivityTaskScheduled() { t.NoError(err) t.NotNil(response) t.Equal(1, len(response.Decisions)) - t.Equal(enums.DecisionTypeCompleteWorkflowExecution, response.Decisions[0].GetDecisionType()) + t.Equal(decisionpb.DecisionTypeCompleteWorkflowExecution, response.Decisions[0].GetDecisionType()) t.NotNil(response.Decisions[0].GetCompleteWorkflowExecutionDecisionAttributes()) } func (t *TaskHandlersTestSuite) TestWorkflowTask_QueryWorkflow_Sticky() { // Schedule an activity and see if we complete workflow. taskList := "sticky-tl" - execution := &commonproto.WorkflowExecution{ + execution := &executionpb.WorkflowExecution{ WorkflowId: "fake-workflow-id", RunId: uuid.New(), } - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(3), - createTestEventDecisionTaskCompleted(4, &commonproto.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2}), - createTestEventActivityTaskScheduled(5, &commonproto.ActivityTaskScheduledEventAttributes{ + createTestEventDecisionTaskCompleted(4, &eventpb.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2}), + createTestEventActivityTaskScheduled(5, &eventpb.ActivityTaskScheduledEventAttributes{ ActivityId: "0", - ActivityType: &commonproto.ActivityType{Name: "Greeter_Activity"}, - TaskList: &commonproto.TaskList{Name: taskList}, + ActivityType: &commonpb.ActivityType{Name: "Greeter_Activity"}, + TaskList: &tasklistpb.TaskList{Name: taskList}, }), - createTestEventActivityTaskStarted(6, &commonproto.ActivityTaskStartedEventAttributes{}), - createTestEventActivityTaskCompleted(7, &commonproto.ActivityTaskCompletedEventAttributes{ScheduledEventId: 5}), + createTestEventActivityTaskStarted(6, &eventpb.ActivityTaskStartedEventAttributes{}), + createTestEventActivityTaskCompleted(7, &eventpb.ActivityTaskCompletedEventAttributes{ScheduledEventId: 5}), } params := workerExecutionParameters{ Namespace: testNamespace, @@ -454,11 +458,11 @@ func (t *TaskHandlersTestSuite) TestWorkflowTask_QueryWorkflow_Sticky() { t.NoError(err) t.NotNil(response) t.Equal(1, len(response.Decisions)) - t.Equal(enums.DecisionTypeScheduleActivityTask, response.Decisions[0].GetDecisionType()) + t.Equal(decisionpb.DecisionTypeScheduleActivityTask, response.Decisions[0].GetDecisionType()) t.NotNil(response.Decisions[0].GetScheduleActivityTaskDecisionAttributes()) // then check the current state using query task - task = createQueryTask([]*commonproto.HistoryEvent{}, 6, "HelloWorld_Workflow", queryType) + task = createQueryTask([]*eventpb.HistoryEvent{}, 6, "HelloWorld_Workflow", queryType) task.WorkflowExecution = execution queryResp, err := taskHandler.ProcessWorkflowTask(&workflowTask{task: task}, nil) t.NoError(err) @@ -468,18 +472,18 @@ func (t *TaskHandlersTestSuite) TestWorkflowTask_QueryWorkflow_Sticky() { func (t *TaskHandlersTestSuite) TestWorkflowTask_QueryWorkflow_NonSticky() { // Schedule an activity and see if we complete workflow. taskList := "tl1" - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(3), - createTestEventDecisionTaskCompleted(4, &commonproto.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2}), - createTestEventActivityTaskScheduled(5, &commonproto.ActivityTaskScheduledEventAttributes{ + createTestEventDecisionTaskCompleted(4, &eventpb.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2}), + createTestEventActivityTaskScheduled(5, &eventpb.ActivityTaskScheduledEventAttributes{ ActivityId: "0", - ActivityType: &commonproto.ActivityType{Name: "Greeter_Activity"}, - TaskList: &commonproto.TaskList{Name: taskList}, + ActivityType: &commonpb.ActivityType{Name: "Greeter_Activity"}, + TaskList: &tasklistpb.TaskList{Name: taskList}, }), - createTestEventActivityTaskStarted(6, &commonproto.ActivityTaskStartedEventAttributes{}), - createTestEventActivityTaskCompleted(7, &commonproto.ActivityTaskCompletedEventAttributes{ScheduledEventId: 5}), + createTestEventActivityTaskStarted(6, &eventpb.ActivityTaskStartedEventAttributes{}), + createTestEventActivityTaskCompleted(7, &eventpb.ActivityTaskCompletedEventAttributes{ScheduledEventId: 5}), createTestEventDecisionTaskStarted(8), createTestEventWorkflowExecutionSignaled(9, "test-signal"), } @@ -539,15 +543,15 @@ func (t *TaskHandlersTestSuite) verifyQueryResult(response interface{}, expected func (t *TaskHandlersTestSuite) TestCacheEvictionWhenErrorOccurs() { taskList := "taskList" - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(3), - createTestEventDecisionTaskCompleted(4, &commonproto.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2}), - createTestEventActivityTaskScheduled(5, &commonproto.ActivityTaskScheduledEventAttributes{ + createTestEventDecisionTaskCompleted(4, &eventpb.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2}), + createTestEventActivityTaskScheduled(5, &eventpb.ActivityTaskScheduledEventAttributes{ ActivityId: "0", - ActivityType: &commonproto.ActivityType{Name: "pkg.Greeter_Activity"}, - TaskList: &commonproto.TaskList{Name: taskList}, + ActivityType: &commonpb.ActivityType{Name: "pkg.Greeter_Activity"}, + TaskList: &tasklistpb.TaskList{Name: taskList}, }), } params := workerExecutionParameters{ @@ -577,12 +581,12 @@ func (t *TaskHandlersTestSuite) TestCacheEvictionWhenErrorOccurs() { func (t *TaskHandlersTestSuite) TestWithMissingHistoryEvents() { taskList := "taskList" - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(3), - createTestEventDecisionTaskCompleted(4, &commonproto.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2}), - createTestEventDecisionTaskScheduled(6, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + createTestEventDecisionTaskCompleted(4, &eventpb.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2}), + createTestEventDecisionTaskScheduled(6, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(7), } params := workerExecutionParameters{ @@ -612,18 +616,18 @@ func (t *TaskHandlersTestSuite) TestWithMissingHistoryEvents() { func (t *TaskHandlersTestSuite) TestWithTruncatedHistory() { taskList := "taskList" - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(3), - createTestEventDecisionTaskFailed(4, &commonproto.DecisionTaskFailedEventAttributes{ScheduledEventId: 2}), - createTestEventDecisionTaskScheduled(5, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + createTestEventDecisionTaskFailed(4, &eventpb.DecisionTaskFailedEventAttributes{ScheduledEventId: 2}), + createTestEventDecisionTaskScheduled(5, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(6), - createTestEventDecisionTaskCompleted(7, &commonproto.DecisionTaskCompletedEventAttributes{ScheduledEventId: 5}), - createTestEventActivityTaskScheduled(8, &commonproto.ActivityTaskScheduledEventAttributes{ + createTestEventDecisionTaskCompleted(7, &eventpb.DecisionTaskCompletedEventAttributes{ScheduledEventId: 5}), + createTestEventActivityTaskScheduled(8, &eventpb.ActivityTaskScheduledEventAttributes{ ActivityId: "0", - ActivityType: &commonproto.ActivityType{Name: "pkg.Greeter_Activity"}, - TaskList: &commonproto.TaskList{Name: taskList}, + ActivityType: &commonpb.ActivityType{Name: "pkg.Greeter_Activity"}, + TaskList: &tasklistpb.TaskList{Name: taskList}, }), } params := workerExecutionParameters{ @@ -697,9 +701,9 @@ func (t *TaskHandlersTestSuite) testSideEffectDeferHelper(disableSticky bool) { ) taskList := "taskList" - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(3), } @@ -733,15 +737,15 @@ func (t *TaskHandlersTestSuite) testSideEffectDeferHelper(disableSticky bool) { func (t *TaskHandlersTestSuite) TestWorkflowTask_NondeterministicDetection() { taskList := "taskList" - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(3), - createTestEventDecisionTaskCompleted(4, &commonproto.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2}), - createTestEventActivityTaskScheduled(5, &commonproto.ActivityTaskScheduledEventAttributes{ + createTestEventDecisionTaskCompleted(4, &eventpb.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2}), + createTestEventActivityTaskScheduled(5, &eventpb.ActivityTaskScheduledEventAttributes{ ActivityId: "0", - ActivityType: &commonproto.ActivityType{Name: "pkg.Greeter_Activity"}, - TaskList: &commonproto.TaskList{Name: taskList}, + ActivityType: &commonpb.ActivityType{Name: "pkg.Greeter_Activity"}, + TaskList: &tasklistpb.TaskList{Name: taskList}, }), } task := createWorkflowTask(testEvents, 3, "HelloWorld_Workflow") @@ -790,7 +794,7 @@ func (t *TaskHandlersTestSuite) TestWorkflowTask_NondeterministicDetection() { // and contains proper justification.(i.e. nondeterminism). t.True(len(response.Decisions) > 0) closeDecision := response.Decisions[len(response.Decisions)-1] - t.Equal(closeDecision.DecisionType, enums.DecisionTypeFailWorkflowExecution) + t.Equal(closeDecision.DecisionType, decisionpb.DecisionTypeFailWorkflowExecution) t.Contains(closeDecision.GetFailWorkflowExecutionDecisionAttributes().Reason, "NonDeterministicWorkflowPolicyFailWorkflow") // now with different package name to activity type @@ -803,9 +807,9 @@ func (t *TaskHandlersTestSuite) TestWorkflowTask_NondeterministicDetection() { func (t *TaskHandlersTestSuite) TestWorkflowTask_WorkflowReturnsPanicError() { taskList := "taskList" - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(3), } task := createWorkflowTask(testEvents, 3, "ReturnPanicWorkflow") @@ -823,7 +827,7 @@ func (t *TaskHandlersTestSuite) TestWorkflowTask_WorkflowReturnsPanicError() { t.NotNil(request) r, ok := request.(*workflowservice.RespondDecisionTaskCompletedRequest) t.True(ok) - t.EqualValues(enums.DecisionTypeFailWorkflowExecution, r.Decisions[0].GetDecisionType()) + t.EqualValues(decisionpb.DecisionTypeFailWorkflowExecution, r.Decisions[0].GetDecisionType()) attr := r.Decisions[0].GetFailWorkflowExecutionDecisionAttributes() t.EqualValues("temporalInternal:Panic", attr.GetReason()) details := string(attr.Details) @@ -832,9 +836,9 @@ func (t *TaskHandlersTestSuite) TestWorkflowTask_WorkflowReturnsPanicError() { func (t *TaskHandlersTestSuite) TestWorkflowTask_WorkflowPanics() { taskList := "taskList" - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(3), } task := createWorkflowTask(testEvents, 3, "PanicWorkflow") @@ -852,7 +856,7 @@ func (t *TaskHandlersTestSuite) TestWorkflowTask_WorkflowPanics() { t.NotNil(request) r, ok := request.(*workflowservice.RespondDecisionTaskFailedRequest) t.True(ok) - t.EqualValues(enums.DecisionTaskFailedCauseWorkflowWorkerUnhandledFailure, r.Cause) + t.EqualValues(eventpb.DecisionTaskFailedCauseWorkflowWorkerUnhandledFailure, r.Cause) t.EqualValues("panicError", string(r.Details)) } @@ -862,7 +866,7 @@ func (t *TaskHandlersTestSuite) TestGetWorkflowInfo() { parentRunID := "parentRun" cronSchedule := "5 4 * * *" continuedRunID := uuid.New() - parentExecution := &commonproto.WorkflowExecution{ + parentExecution := &executionpb.WorkflowExecution{ WorkflowId: parentID, RunId: parentRunID, } @@ -873,9 +877,9 @@ func (t *TaskHandlersTestSuite) TestGetWorkflowInfo() { workflowType := "GetWorkflowInfoWorkflow" lastCompletionResult, err := getDefaultDataConverter().ToData("lastCompletionData") t.NoError(err) - startedEventAttributes := &commonproto.WorkflowExecutionStartedEventAttributes{ + startedEventAttributes := &eventpb.WorkflowExecutionStartedEventAttributes{ Input: lastCompletionResult, - TaskList: &commonproto.TaskList{Name: taskList}, + TaskList: &tasklistpb.TaskList{Name: taskList}, ParentWorkflowExecution: parentExecution, CronSchedule: cronSchedule, ContinuedExecutionRunId: continuedRunID, @@ -885,9 +889,9 @@ func (t *TaskHandlersTestSuite) TestGetWorkflowInfo() { TaskStartToCloseTimeoutSeconds: taskTimeout, LastCompletionResult: lastCompletionResult, } - testEvents := []*commonproto.HistoryEvent{ + testEvents := []*eventpb.HistoryEvent{ createTestEventWorkflowExecutionStarted(1, startedEventAttributes), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(3), } task := createWorkflowTask(testEvents, 3, workflowType) @@ -905,7 +909,7 @@ func (t *TaskHandlersTestSuite) TestGetWorkflowInfo() { t.NotNil(request) r, ok := request.(*workflowservice.RespondDecisionTaskCompletedRequest) t.True(ok) - t.EqualValues(enums.DecisionTypeCompleteWorkflowExecution, r.Decisions[0].GetDecisionType()) + t.EqualValues(decisionpb.DecisionTypeCompleteWorkflowExecution, r.Decisions[0].GetDecisionType()) attr := r.Decisions[0].GetCompleteWorkflowExecutionDecisionAttributes() var result WorkflowInfo t.NoError(getDefaultDataConverter().FromData(attr.Result, &result)) @@ -934,8 +938,8 @@ func (t *TaskHandlersTestSuite) TestConsistentQuery_InvalidQueryTask() { taskHandler := newWorkflowTaskHandler(params, nil, t.registry) task := createWorkflowTask(nil, 3, "HelloWorld_Workflow") - task.Query = &commonproto.WorkflowQuery{} - task.Queries = map[string]*commonproto.WorkflowQuery{"query_id": {}} + task.Query = &querypb.WorkflowQuery{} + task.Queries = map[string]*querypb.WorkflowQuery{"query_id": {}} newWorkflowTaskWorkerInternal(taskHandler, t.service, params, make(chan struct{})) // query and queries are both specified so this is an invalid task request, err := taskHandler.ProcessWorkflowTask(&workflowTask{task: task}, nil) @@ -955,21 +959,21 @@ func (t *TaskHandlersTestSuite) TestConsistentQuery_Success() { t.NoError(err) signal, err := getDefaultDataConverter().ToData("signal data") t.NoError(err) - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{ - TaskList: &commonproto.TaskList{Name: taskList}, + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{ + TaskList: &tasklistpb.TaskList{Name: taskList}, Input: numberOfSignalsToComplete, }), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{}), createTestEventDecisionTaskStarted(3), - createTestEventDecisionTaskCompleted(4, &commonproto.DecisionTaskCompletedEventAttributes{ + createTestEventDecisionTaskCompleted(4, &eventpb.DecisionTaskCompletedEventAttributes{ ScheduledEventId: 2, BinaryChecksum: checksum1}), createTestEventWorkflowExecutionSignaledWithPayload(5, signalCh, signal), - createTestEventDecisionTaskScheduled(6, &commonproto.DecisionTaskScheduledEventAttributes{}), + createTestEventDecisionTaskScheduled(6, &eventpb.DecisionTaskScheduledEventAttributes{}), createTestEventDecisionTaskStarted(7), } - queries := map[string]*commonproto.WorkflowQuery{ + queries := map[string]*querypb.WorkflowQuery{ "id1": {QueryType: queryType}, "id2": {QueryType: errQueryType}, } @@ -988,13 +992,13 @@ func (t *TaskHandlersTestSuite) TestConsistentQuery_Success() { t.NoError(err) t.NotNil(response) t.Len(response.Decisions, 0) - expectedQueryResults := map[string]*commonproto.WorkflowQueryResult{ + expectedQueryResults := map[string]*querypb.WorkflowQueryResult{ "id1": { - ResultType: enums.QueryResultTypeAnswered, + ResultType: querypb.QueryResultTypeAnswered, Answer: []byte(fmt.Sprintf("\"%v\"\n", startingQueryValue)), }, "id2": { - ResultType: enums.QueryResultTypeFailed, + ResultType: querypb.QueryResultTypeFailed, ErrorMessage: queryErr, }, } @@ -1007,13 +1011,13 @@ func (t *TaskHandlersTestSuite) TestConsistentQuery_Success() { t.NoError(err) t.NotNil(response) t.Len(response.Decisions, 1) - expectedQueryResults = map[string]*commonproto.WorkflowQueryResult{ + expectedQueryResults = map[string]*querypb.WorkflowQueryResult{ "id1": { - ResultType: enums.QueryResultTypeAnswered, + ResultType: querypb.QueryResultTypeAnswered, Answer: []byte(fmt.Sprintf("\"%v\"\n", "signal data")), }, "id2": { - ResultType: enums.QueryResultTypeFailed, + ResultType: querypb.QueryResultTypeFailed, ErrorMessage: queryErr, }, } @@ -1023,7 +1027,7 @@ func (t *TaskHandlersTestSuite) TestConsistentQuery_Success() { getWorkflowCache().Delete(task.WorkflowExecution.RunId) } -func (t *TaskHandlersTestSuite) assertQueryResultsEqual(expected map[string]*commonproto.WorkflowQueryResult, actual map[string]*commonproto.WorkflowQueryResult) { +func (t *TaskHandlersTestSuite) assertQueryResultsEqual(expected map[string]*querypb.WorkflowQueryResult, actual map[string]*querypb.WorkflowQueryResult) { t.Equal(len(expected), len(actual)) for expectedID, expectedResult := range expected { t.Contains(actual, expectedID) @@ -1034,9 +1038,9 @@ func (t *TaskHandlersTestSuite) assertQueryResultsEqual(expected map[string]*com func (t *TaskHandlersTestSuite) TestWorkflowTask_CancelActivityBeforeSent() { // Schedule an activity and see if we complete workflow. taskList := "tl1" - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{}), + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{}), createTestEventDecisionTaskStarted(3), } task := createWorkflowTask(testEvents, 0, "HelloWorld_WorkflowCancel") @@ -1053,16 +1057,16 @@ func (t *TaskHandlersTestSuite) TestWorkflowTask_CancelActivityBeforeSent() { t.NoError(err) t.NotNil(response) t.Equal(1, len(response.Decisions)) - t.Equal(enums.DecisionTypeCompleteWorkflowExecution, response.Decisions[0].GetDecisionType()) + t.Equal(decisionpb.DecisionTypeCompleteWorkflowExecution, response.Decisions[0].GetDecisionType()) t.NotNil(response.Decisions[0].GetCompleteWorkflowExecutionDecisionAttributes()) } func (t *TaskHandlersTestSuite) TestWorkflowTask_PageToken() { // Schedule a decision activity and see if we complete workflow. taskList := "tl1" - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{}), + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{}), } task := createWorkflowTask(testEvents, 0, "HelloWorld_Workflow") task.NextPageToken = []byte("token") @@ -1074,13 +1078,13 @@ func (t *TaskHandlersTestSuite) TestWorkflowTask_PageToken() { Logger: t.logger, } - nextEvents := []*commonproto.HistoryEvent{ + nextEvents := []*eventpb.HistoryEvent{ createTestEventDecisionTaskStarted(3), } historyIterator := &historyIteratorImpl{ - iteratorFunc: func(nextToken []byte) (*commonproto.History, []byte, error) { - return &commonproto.History{Events: nextEvents}, nil, nil + iteratorFunc: func(nextToken []byte) (*eventpb.History, []byte, error) { + return &eventpb.History{Events: nextEvents}, nil, nil }, } taskHandler := newWorkflowTaskHandler(params, nil, t.registry) @@ -1120,13 +1124,13 @@ func (t *TaskHandlersTestSuite) TestLocalActivityRetry_DecisionHeartbeatFail() { decisionTaskStartedEvent := createTestEventDecisionTaskStarted(3) decisionTaskStartedEvent.Timestamp = time.Now().UnixNano() - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{ + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{ // make sure the timeout is same as the backoff interval TaskStartToCloseTimeoutSeconds: backoffIntervalInSeconds, - TaskList: &commonproto.TaskList{Name: testWorkflowTaskTasklist}}, + TaskList: &tasklistpb.TaskList{Name: testWorkflowTaskTasklist}}, ), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{}), decisionTaskStartedEvent, } @@ -1305,16 +1309,16 @@ func (t *TaskHandlersTestSuite) TestActivityExecutionDeadline() { activityHandler := newActivityTaskHandler(mockService, wep, registry) pats := &workflowservice.PollForActivityTaskResponse{ TaskToken: []byte("token"), - WorkflowExecution: &commonproto.WorkflowExecution{ + WorkflowExecution: &executionpb.WorkflowExecution{ WorkflowId: "wID", RunId: "rID"}, - ActivityType: &commonproto.ActivityType{Name: "test"}, + ActivityType: &commonpb.ActivityType{Name: "test"}, ActivityId: uuid.New(), ScheduledTimestamp: d.ScheduleTS.UnixNano(), ScheduleToCloseTimeoutSeconds: d.ScheduleDuration, StartedTimestamp: d.StartTS.UnixNano(), StartToCloseTimeoutSeconds: d.StartDuration, - WorkflowType: &commonproto.WorkflowType{ + WorkflowType: &commonpb.WorkflowType{ Name: "wType", }, WorkflowNamespace: "namespace", @@ -1360,16 +1364,16 @@ func (t *TaskHandlersTestSuite) TestActivityExecutionWorkerStop() { activityHandler := newActivityTaskHandler(mockService, wep, registry) pats := &workflowservice.PollForActivityTaskResponse{ TaskToken: []byte("token"), - WorkflowExecution: &commonproto.WorkflowExecution{ + WorkflowExecution: &executionpb.WorkflowExecution{ WorkflowId: "wID", RunId: "rID"}, - ActivityType: &commonproto.ActivityType{Name: "test"}, + ActivityType: &commonpb.ActivityType{Name: "test"}, ActivityId: uuid.New(), ScheduledTimestamp: time.Now().UnixNano(), ScheduleToCloseTimeoutSeconds: 1, StartedTimestamp: time.Now().UnixNano(), StartToCloseTimeoutSeconds: 1, - WorkflowType: &commonproto.WorkflowType{ + WorkflowType: &commonpb.WorkflowType{ Name: "wType", }, WorkflowNamespace: "namespace", @@ -1381,15 +1385,15 @@ func (t *TaskHandlersTestSuite) TestActivityExecutionWorkerStop() { } func Test_NonDeterministicCheck(t *testing.T) { - decisionTypes := enums.DecisionType_value + decisionTypes := decisionpb.DecisionType_value require.Equal(t, 13, len(decisionTypes), "If you see this error, you are adding new decision type. "+ "Before updating the number to make this test pass, please make sure you update isDecisionMatchEvent() method "+ "to check the new decision type. Otherwise the replay will fail on the new decision event.") - eventTypes := enums.EventType_value + eventTypes := eventpb.EventType_value decisionEventTypeCount := 0 for _, et := range eventTypes { - if isDecisionEvent(enums.EventType(et)) { + if isDecisionEvent(eventpb.EventType(et)) { decisionEventTypeCount++ } } @@ -1399,52 +1403,52 @@ func Test_NonDeterministicCheck(t *testing.T) { } func Test_IsDecisionMatchEvent_UpsertWorkflowSearchAttributes(t *testing.T) { - diType := enums.DecisionTypeUpsertWorkflowSearchAttributes - eType := enums.EventTypeUpsertWorkflowSearchAttributes + diType := decisionpb.DecisionTypeUpsertWorkflowSearchAttributes + eType := eventpb.EventTypeUpsertWorkflowSearchAttributes strictMode := false testCases := []struct { name string - decision *commonproto.Decision - event *commonproto.HistoryEvent + decision *decisionpb.Decision + event *eventpb.HistoryEvent expected bool }{ { name: "event type not match", - decision: &commonproto.Decision{ + decision: &decisionpb.Decision{ DecisionType: diType, - Attributes: &commonproto.Decision_UpsertWorkflowSearchAttributesDecisionAttributes{UpsertWorkflowSearchAttributesDecisionAttributes: &commonproto.UpsertWorkflowSearchAttributesDecisionAttributes{ - SearchAttributes: &commonproto.SearchAttributes{}, + Attributes: &decisionpb.Decision_UpsertWorkflowSearchAttributesDecisionAttributes{UpsertWorkflowSearchAttributesDecisionAttributes: &decisionpb.UpsertWorkflowSearchAttributesDecisionAttributes{ + SearchAttributes: &commonpb.SearchAttributes{}, }}, }, - event: &commonproto.HistoryEvent{}, + event: &eventpb.HistoryEvent{}, expected: false, }, { name: "attributes not match", - decision: &commonproto.Decision{ + decision: &decisionpb.Decision{ DecisionType: diType, - Attributes: &commonproto.Decision_UpsertWorkflowSearchAttributesDecisionAttributes{UpsertWorkflowSearchAttributesDecisionAttributes: &commonproto.UpsertWorkflowSearchAttributesDecisionAttributes{ - SearchAttributes: &commonproto.SearchAttributes{}, + Attributes: &decisionpb.Decision_UpsertWorkflowSearchAttributesDecisionAttributes{UpsertWorkflowSearchAttributesDecisionAttributes: &decisionpb.UpsertWorkflowSearchAttributesDecisionAttributes{ + SearchAttributes: &commonpb.SearchAttributes{}, }}, }, - event: &commonproto.HistoryEvent{ + event: &eventpb.HistoryEvent{ EventType: eType, - Attributes: &commonproto.HistoryEvent_UpsertWorkflowSearchAttributesEventAttributes{UpsertWorkflowSearchAttributesEventAttributes: &commonproto.UpsertWorkflowSearchAttributesEventAttributes{}}}, + Attributes: &eventpb.HistoryEvent_UpsertWorkflowSearchAttributesEventAttributes{UpsertWorkflowSearchAttributesEventAttributes: &eventpb.UpsertWorkflowSearchAttributesEventAttributes{}}}, expected: true, }, { name: "attributes match", - decision: &commonproto.Decision{ + decision: &decisionpb.Decision{ DecisionType: diType, - Attributes: &commonproto.Decision_UpsertWorkflowSearchAttributesDecisionAttributes{UpsertWorkflowSearchAttributesDecisionAttributes: &commonproto.UpsertWorkflowSearchAttributesDecisionAttributes{ - SearchAttributes: &commonproto.SearchAttributes{}, + Attributes: &decisionpb.Decision_UpsertWorkflowSearchAttributesDecisionAttributes{UpsertWorkflowSearchAttributesDecisionAttributes: &decisionpb.UpsertWorkflowSearchAttributesDecisionAttributes{ + SearchAttributes: &commonpb.SearchAttributes{}, }}, }, - event: &commonproto.HistoryEvent{ + event: &eventpb.HistoryEvent{ EventType: eType, - Attributes: &commonproto.HistoryEvent_UpsertWorkflowSearchAttributesEventAttributes{UpsertWorkflowSearchAttributesEventAttributes: &commonproto.UpsertWorkflowSearchAttributesEventAttributes{ - SearchAttributes: &commonproto.SearchAttributes{}, + Attributes: &eventpb.HistoryEvent_UpsertWorkflowSearchAttributesEventAttributes{UpsertWorkflowSearchAttributesEventAttributes: &eventpb.UpsertWorkflowSearchAttributesEventAttributes{ + SearchAttributes: &commonpb.SearchAttributes{}, }}, }, expected: true, @@ -1461,21 +1465,21 @@ func Test_IsDecisionMatchEvent_UpsertWorkflowSearchAttributes(t *testing.T) { testCases = []struct { name string - decision *commonproto.Decision - event *commonproto.HistoryEvent + decision *decisionpb.Decision + event *eventpb.HistoryEvent expected bool }{ { name: "attributes not match", - decision: &commonproto.Decision{ + decision: &decisionpb.Decision{ DecisionType: diType, - Attributes: &commonproto.Decision_UpsertWorkflowSearchAttributesDecisionAttributes{UpsertWorkflowSearchAttributesDecisionAttributes: &commonproto.UpsertWorkflowSearchAttributesDecisionAttributes{ - SearchAttributes: &commonproto.SearchAttributes{}, + Attributes: &decisionpb.Decision_UpsertWorkflowSearchAttributesDecisionAttributes{UpsertWorkflowSearchAttributesDecisionAttributes: &decisionpb.UpsertWorkflowSearchAttributesDecisionAttributes{ + SearchAttributes: &commonpb.SearchAttributes{}, }}, }, - event: &commonproto.HistoryEvent{ + event: &eventpb.HistoryEvent{ EventType: eType, - Attributes: &commonproto.HistoryEvent_UpsertWorkflowSearchAttributesEventAttributes{UpsertWorkflowSearchAttributesEventAttributes: &commonproto.UpsertWorkflowSearchAttributesEventAttributes{}}}, + Attributes: &eventpb.HistoryEvent_UpsertWorkflowSearchAttributesEventAttributes{UpsertWorkflowSearchAttributesEventAttributes: &eventpb.UpsertWorkflowSearchAttributesEventAttributes{}}}, expected: false, }, } @@ -1490,8 +1494,8 @@ func Test_IsDecisionMatchEvent_UpsertWorkflowSearchAttributes(t *testing.T) { func Test_IsSearchAttributesMatched(t *testing.T) { testCases := []struct { name string - lhs *commonproto.SearchAttributes - rhs *commonproto.SearchAttributes + lhs *commonpb.SearchAttributes + rhs *commonpb.SearchAttributes expected bool }{ { @@ -1503,35 +1507,35 @@ func Test_IsSearchAttributesMatched(t *testing.T) { { name: "left nil", lhs: nil, - rhs: &commonproto.SearchAttributes{}, + rhs: &commonpb.SearchAttributes{}, expected: false, }, { name: "right nil", - lhs: &commonproto.SearchAttributes{}, + lhs: &commonpb.SearchAttributes{}, rhs: nil, expected: false, }, { name: "not match", - lhs: &commonproto.SearchAttributes{ + lhs: &commonpb.SearchAttributes{ IndexedFields: map[string][]byte{ "key1": []byte("1"), "key2": []byte("abc"), }, }, - rhs: &commonproto.SearchAttributes{}, + rhs: &commonpb.SearchAttributes{}, expected: false, }, { name: "match", - lhs: &commonproto.SearchAttributes{ + lhs: &commonpb.SearchAttributes{ IndexedFields: map[string][]byte{ "key1": []byte("1"), "key2": []byte("abc"), }, }, - rhs: &commonproto.SearchAttributes{ + rhs: &commonpb.SearchAttributes{ IndexedFields: map[string][]byte{ "key2": []byte("abc"), "key1": []byte("1"), diff --git a/internal/internal_task_pollers.go b/internal/internal_task_pollers.go index 63af0208a..99259a384 100644 --- a/internal/internal_task_pollers.go +++ b/internal/internal_task_pollers.go @@ -34,8 +34,10 @@ import ( "github.com/uber-go/tally" "go.uber.org/zap" - commonproto "go.temporal.io/temporal-proto/common" - "go.temporal.io/temporal-proto/enums" + decisionpb "go.temporal.io/temporal-proto/decision" + eventpb "go.temporal.io/temporal-proto/event" + executionpb "go.temporal.io/temporal-proto/execution" + tasklistpb "go.temporal.io/temporal-proto/tasklist" "go.temporal.io/temporal-proto/workflowservice" "go.temporal.io/temporal/internal/common" @@ -100,8 +102,8 @@ type ( } historyIteratorImpl struct { - iteratorFunc func(nextPageToken []byte) (*commonproto.History, []byte, error) - execution *commonproto.WorkflowExecution + iteratorFunc func(nextPageToken []byte) (*eventpb.History, []byte, error) + execution *executionpb.WorkflowExecution nextPageToken []byte namespace string service workflowservice.WorkflowServiceClient @@ -374,8 +376,8 @@ func (wtp *workflowTaskPoller) RespondTaskCompleted(completedRequest interface{} } case *workflowservice.RespondDecisionTaskCompletedRequest: if request.StickyAttributes == nil && !wtp.disableStickyExecution { - request.StickyAttributes = &commonproto.StickyExecutionAttributes{ - WorkerTaskList: &commonproto.TaskList{Name: getWorkerTaskList(wtp.stickyUUID)}, + request.StickyAttributes = &decisionpb.StickyExecutionAttributes{ + WorkerTaskList: &tasklistpb.TaskList{Name: getWorkerTaskList(wtp.stickyUUID)}, ScheduleToStartTimeoutSeconds: common.Int32Ceil(wtp.StickyScheduleToStartTimeout.Seconds()), } } else { @@ -566,13 +568,13 @@ WaitResult: return &localActivityResult{result: laResult, err: err, task: task} } -func (wtp *workflowTaskPoller) release(kind enums.TaskListKind) { +func (wtp *workflowTaskPoller) release(kind tasklistpb.TaskListKind) { if wtp.disableStickyExecution { return } wtp.requestLock.Lock() - if kind == enums.TaskListKindSticky { + if kind == tasklistpb.TaskListKindSticky { wtp.pendingStickyPollCount-- } else { wtp.pendingRegularPollCount-- @@ -580,8 +582,8 @@ func (wtp *workflowTaskPoller) release(kind enums.TaskListKind) { wtp.requestLock.Unlock() } -func (wtp *workflowTaskPoller) updateBacklog(taskListKind enums.TaskListKind, backlogCountHint int64) { - if taskListKind == enums.TaskListKindNormal || wtp.disableStickyExecution { +func (wtp *workflowTaskPoller) updateBacklog(taskListKind tasklistpb.TaskListKind, backlogCountHint int64) { + if taskListKind == tasklistpb.TaskListKindNormal || wtp.disableStickyExecution { // we only care about sticky backlog for now. return } @@ -599,20 +601,20 @@ func (wtp *workflowTaskPoller) updateBacklog(taskListKind enums.TaskListKind, ba // TODO: make this more smart to auto adjust based on poll latency func (wtp *workflowTaskPoller) getNextPollRequest() (request *workflowservice.PollForDecisionTaskRequest) { taskListName := wtp.taskListName - taskListKind := enums.TaskListKindNormal + taskListKind := tasklistpb.TaskListKindNormal if !wtp.disableStickyExecution { wtp.requestLock.Lock() if wtp.stickyBacklog > 0 || wtp.pendingStickyPollCount <= wtp.pendingRegularPollCount { wtp.pendingStickyPollCount++ taskListName = getWorkerTaskList(wtp.stickyUUID) - taskListKind = enums.TaskListKindSticky + taskListKind = tasklistpb.TaskListKindSticky } else { wtp.pendingRegularPollCount++ } wtp.requestLock.Unlock() } - taskList := &commonproto.TaskList{ + taskList := &tasklistpb.TaskList{ Name: taskListName, Kind: taskListKind, } @@ -692,7 +694,7 @@ func (wtp *workflowTaskPoller) toWorkflowTask(response *workflowservice.PollForD return task } -func (h *historyIteratorImpl) GetNextPage() (*commonproto.History, error) { +func (h *historyIteratorImpl) GetNextPage() (*eventpb.History, error) { if h.iteratorFunc == nil { h.iteratorFunc = newGetHistoryPageFunc( context.Background(), @@ -723,11 +725,11 @@ func newGetHistoryPageFunc( ctx context.Context, service workflowservice.WorkflowServiceClient, namespace string, - execution *commonproto.WorkflowExecution, + execution *executionpb.WorkflowExecution, atDecisionTaskCompletedEventID int64, metricsScope tally.Scope, -) func(nextPageToken []byte) (*commonproto.History, []byte, error) { - return func(nextPageToken []byte) (*commonproto.History, []byte, error) { +) func(nextPageToken []byte) (*eventpb.History, []byte, error) { + return func(nextPageToken []byte) (*eventpb.History, []byte, error) { metricsScope.Counter(metrics.WorkflowGetHistoryCounter).Inc(1) startTime := time.Now() var resp *workflowservice.GetWorkflowExecutionHistoryResponse @@ -757,7 +759,7 @@ func newGetHistoryPageFunc( h.Events[size-1].GetEventId() > atDecisionTaskCompletedEventID { first := h.Events[0].GetEventId() // eventIds start from 1 h.Events = h.Events[:atDecisionTaskCompletedEventID-first+1] - if h.Events[len(h.Events)-1].GetEventType() != enums.EventTypeDecisionTaskCompleted { + if h.Events[len(h.Events)-1].GetEventType() != eventpb.EventTypeDecisionTaskCompleted { return nil, nil, fmt.Errorf("newGetHistoryPageFunc: atDecisionTaskCompletedEventID(%v) "+ "points to event that is not DecisionTaskCompleted", atDecisionTaskCompletedEventID) } @@ -792,9 +794,9 @@ func (atp *activityTaskPoller) poll(ctx context.Context) (interface{}, error) { }) request := &workflowservice.PollForActivityTaskRequest{ Namespace: atp.namespace, - TaskList: &commonproto.TaskList{Name: atp.taskListName}, + TaskList: &tasklistpb.TaskList{Name: atp.taskListName}, Identity: atp.identity, - TaskListMetadata: &commonproto.TaskListMetadata{MaxTasksPerSecond: &types.DoubleValue{Value: atp.activitiesPerSecond}}, + TaskListMetadata: &tasklistpb.TaskListMetadata{MaxTasksPerSecond: &types.DoubleValue{Value: atp.activitiesPerSecond}}, } response, err := atp.service.PollForActivityTask(ctx, request) diff --git a/internal/internal_utils.go b/internal/internal_utils.go index 46a7f47ed..a07006d47 100644 --- a/internal/internal_utils.go +++ b/internal/internal_utils.go @@ -35,7 +35,7 @@ import ( "github.com/uber-go/tally" "google.golang.org/grpc/metadata" - "go.temporal.io/temporal-proto/enums" + eventpb "go.temporal.io/temporal-proto/event" "go.temporal.io/temporal/internal/common/metrics" ) @@ -271,11 +271,11 @@ func getMetricsScopeForLocalActivity(ts *metrics.TaggedScope, workflowType, loca return ts.GetTaggedScope(tagWorkflowType, workflowType, tagLocalActivityType, localActivityType) } -func getTimeoutTypeFromErrReason(reason string) (enums.TimeoutType, error) { +func getTimeoutTypeFromErrReason(reason string) (eventpb.TimeoutType, error) { // "reason" is a string like "temporalInternal:Timeout TimeoutTypeStartToClose" timeoutTypeStr := reason[strings.Index(reason, " ")+1:] - if timeoutType, found := enums.TimeoutType_value[timeoutTypeStr]; found { - return enums.TimeoutType(timeoutType), nil + if timeoutType, found := eventpb.TimeoutType_value[timeoutTypeStr]; found { + return eventpb.TimeoutType(timeoutType), nil } // this happens when the timeout error reason is constructed by an prior constructed by prior client version diff --git a/internal/internal_utils_test.go b/internal/internal_utils_test.go index 6d2fdf496..2e46bdcd1 100644 --- a/internal/internal_utils_test.go +++ b/internal/internal_utils_test.go @@ -26,7 +26,7 @@ import ( "time" "github.com/stretchr/testify/require" - "go.temporal.io/temporal-proto/enums" + eventpb "go.temporal.io/temporal-proto/event" ) func TestChannelBuilderOptions(t *testing.T) { @@ -121,16 +121,16 @@ func TestGetErrorDetails_TimeoutError(t *testing.T) { require.NoError(t, err) val := newEncodedValues(details, dc).(*EncodedValues) - timeoutErr1 := NewTimeoutError(enums.TimeoutTypeScheduleToStart, val) + timeoutErr1 := NewTimeoutError(eventpb.TimeoutTypeScheduleToStart, val) reason, data := getErrorDetails(timeoutErr1, dc) - require.Equal(t, fmt.Sprintf("%v %v", errReasonTimeout, enums.TimeoutTypeScheduleToStart), reason) + require.Equal(t, fmt.Sprintf("%v %v", errReasonTimeout, eventpb.TimeoutTypeScheduleToStart), reason) require.Equal(t, val.values, data) - timeoutErr2 := NewTimeoutError(enums.TimeoutTypeHeartbeat, testErrorDetails4) + timeoutErr2 := NewTimeoutError(eventpb.TimeoutTypeHeartbeat, testErrorDetails4) val2, err := encodeArgs(dc, []interface{}{testErrorDetails4}) require.NoError(t, err) reason, data = getErrorDetails(timeoutErr2, dc) - require.Equal(t, fmt.Sprintf("%v %v", errReasonTimeout, enums.TimeoutTypeHeartbeat), reason) + require.Equal(t, fmt.Sprintf("%v %v", errReasonTimeout, eventpb.TimeoutTypeHeartbeat), reason) require.Equal(t, val2, data) } @@ -140,7 +140,7 @@ func TestConstructError_TimeoutError(t *testing.T) { details, err := dc.ToData(testErrorDetails1) require.NoError(t, err) - reason := fmt.Sprintf("%v %v", errReasonTimeout, enums.TimeoutTypeHeartbeat) + reason := fmt.Sprintf("%v %v", errReasonTimeout, eventpb.TimeoutTypeHeartbeat) constructedErr := constructError(reason, details, dc) timeoutErr, ok := constructedErr.(*TimeoutError) require.True(t, ok) @@ -152,11 +152,11 @@ func TestConstructError_TimeoutError(t *testing.T) { // Backward compatibility test reason = errReasonTimeout - details, err = dc.ToData(enums.TimeoutTypeHeartbeat) + details, err = dc.ToData(eventpb.TimeoutTypeHeartbeat) require.NoError(t, err) constructedErr = constructError(reason, details, dc) timeoutErr, ok = constructedErr.(*TimeoutError) require.True(t, ok) - require.Equal(t, enums.TimeoutTypeHeartbeat, timeoutErr.TimeoutType()) + require.Equal(t, eventpb.TimeoutTypeHeartbeat, timeoutErr.TimeoutType()) require.False(t, timeoutErr.HasDetails()) } diff --git a/internal/internal_worker.go b/internal/internal_worker.go index bb50ed155..7615925e3 100644 --- a/internal/internal_worker.go +++ b/internal/internal_worker.go @@ -44,8 +44,10 @@ import ( "github.com/opentracing/opentracing-go" "github.com/pborman/uuid" "github.com/uber-go/tally" - commonproto "go.temporal.io/temporal-proto/common" - "go.temporal.io/temporal-proto/enums" + + decisionpb "go.temporal.io/temporal-proto/decision" + eventpb "go.temporal.io/temporal-proto/event" + executionpb "go.temporal.io/temporal-proto/execution" "go.temporal.io/temporal-proto/serviceerror" "go.temporal.io/temporal-proto/workflowservice" "go.temporal.io/temporal-proto/workflowservicemock" @@ -1137,7 +1139,7 @@ func (aw *WorkflowReplayer) RegisterWorkflowWithOptions(w interface{}, options R // ReplayWorkflowHistory executes a single decision task for the given history. // Use for testing the backwards compatibility of code changes and troubleshooting workflows in a debugger. // The logger is an optional parameter. Defaults to the noop logger. -func (aw *WorkflowReplayer) ReplayWorkflowHistory(logger *zap.Logger, history *commonproto.History) error { +func (aw *WorkflowReplayer) ReplayWorkflowHistory(logger *zap.Logger, history *eventpb.History) error { if logger == nil { logger = zap.NewNop() } @@ -1180,7 +1182,7 @@ func (aw *WorkflowReplayer) ReplayPartialWorkflowHistoryFromJSONFile(logger *zap // ReplayWorkflowExecution replays workflow execution loading it from Temporal service. func (aw *WorkflowReplayer) ReplayWorkflowExecution(ctx context.Context, service workflowservice.WorkflowServiceClient, logger *zap.Logger, namespace string, execution WorkflowExecution) error { - sharedExecution := &commonproto.WorkflowExecution{ + sharedExecution := &executionpb.WorkflowExecution{ RunId: execution.RunID, WorkflowId: execution.ID, } @@ -1196,7 +1198,7 @@ func (aw *WorkflowReplayer) ReplayWorkflowExecution(ctx context.Context, service return aw.replayWorkflowHistory(logger, service, namespace, hResponse.History) } -func (aw *WorkflowReplayer) replayWorkflowHistory(logger *zap.Logger, service workflowservice.WorkflowServiceClient, namespace string, history *commonproto.History) error { +func (aw *WorkflowReplayer) replayWorkflowHistory(logger *zap.Logger, service workflowservice.WorkflowServiceClient, namespace string, history *eventpb.History) error { taskList := "ReplayTaskList" events := history.Events if events == nil { @@ -1206,7 +1208,7 @@ func (aw *WorkflowReplayer) replayWorkflowHistory(logger *zap.Logger, service wo return errors.New("at least 3 events expected in the history") } first := events[0] - if first.GetEventType() != enums.EventTypeWorkflowExecutionStarted { + if first.GetEventType() != eventpb.EventTypeWorkflowExecutionStarted { return errors.New("first event is not WorkflowExecutionStarted") } last := events[len(events)-1] @@ -1216,7 +1218,7 @@ func (aw *WorkflowReplayer) replayWorkflowHistory(logger *zap.Logger, service wo return errors.New("corrupted WorkflowExecutionStarted") } workflowType := attr.WorkflowType - execution := &commonproto.WorkflowExecution{ + execution := &executionpb.WorkflowExecution{ RunId: uuid.NewRandom().String(), WorkflowId: "ReplayId", } @@ -1257,7 +1259,7 @@ func (aw *WorkflowReplayer) replayWorkflowHistory(logger *zap.Logger, service wo return err } - if last.GetEventType() != enums.EventTypeWorkflowExecutionCompleted && last.GetEventType() != enums.EventTypeWorkflowExecutionContinuedAsNew { + if last.GetEventType() != eventpb.EventTypeWorkflowExecutionCompleted && last.GetEventType() != eventpb.EventTypeWorkflowExecutionContinuedAsNew { return nil } err = fmt.Errorf("replay workflow doesn't return the same result as the last event, resp: %v, last: %v", resp, last) @@ -1265,8 +1267,8 @@ func (aw *WorkflowReplayer) replayWorkflowHistory(logger *zap.Logger, service wo completeReq, ok := resp.(*workflowservice.RespondDecisionTaskCompletedRequest) if ok { for _, d := range completeReq.Decisions { - if d.GetDecisionType() == enums.DecisionTypeContinueAsNewWorkflowExecution { - if last.GetEventType() == enums.EventTypeWorkflowExecutionContinuedAsNew { + if d.GetDecisionType() == decisionpb.DecisionTypeContinueAsNewWorkflowExecution { + if last.GetEventType() == eventpb.EventTypeWorkflowExecutionContinuedAsNew { inputA := d.GetContinueAsNewWorkflowExecutionDecisionAttributes().Input inputB := last.GetWorkflowExecutionContinuedAsNewEventAttributes().Input if bytes.Equal(inputA, inputB) { @@ -1274,8 +1276,8 @@ func (aw *WorkflowReplayer) replayWorkflowHistory(logger *zap.Logger, service wo } } } - if d.GetDecisionType() == enums.DecisionTypeCompleteWorkflowExecution { - if last.GetEventType() == enums.EventTypeWorkflowExecutionCompleted { + if d.GetDecisionType() == decisionpb.DecisionTypeCompleteWorkflowExecution { + if last.GetEventType() == eventpb.EventTypeWorkflowExecutionCompleted { resultA := last.GetWorkflowExecutionCompletedEventAttributes().Result resultB := d.GetCompleteWorkflowExecutionDecisionAttributes().Result if bytes.Equal(resultA, resultB) { @@ -1289,13 +1291,13 @@ func (aw *WorkflowReplayer) replayWorkflowHistory(logger *zap.Logger, service wo return err } -func extractHistoryFromFile(jsonfileName string, lastEventID int64) (*commonproto.History, error) { +func extractHistoryFromFile(jsonfileName string, lastEventID int64) (*eventpb.History, error) { reader, err := os.Open(jsonfileName) if err != nil { return nil, err } - var deserializedHistory commonproto.History + var deserializedHistory eventpb.History err = jsonpb.Unmarshal(reader, &deserializedHistory) if err != nil { @@ -1307,7 +1309,7 @@ func extractHistoryFromFile(jsonfileName string, lastEventID int64) (*commonprot } // Caller is potentially asking for subset of history instead of all history events - var events []*commonproto.HistoryEvent + var events []*eventpb.HistoryEvent for _, event := range deserializedHistory.Events { events = append(events, event) if event.GetEventId() == lastEventID { @@ -1315,7 +1317,7 @@ func extractHistoryFromFile(jsonfileName string, lastEventID int64) (*commonprot break } } - history := &commonproto.History{Events: events} + history := &eventpb.History{Events: events} return history, nil } diff --git a/internal/internal_worker_base.go b/internal/internal_worker_base.go index 1259a4b50..22ad710b7 100644 --- a/internal/internal_worker_base.go +++ b/internal/internal_worker_base.go @@ -34,7 +34,7 @@ import ( "go.uber.org/zap/zapcore" "golang.org/x/time/rate" - commonproto "go.temporal.io/temporal-proto/common" + commonpb "go.temporal.io/temporal-proto/common" "go.temporal.io/temporal/internal/common/backoff" "go.temporal.io/temporal/internal/common/metrics" @@ -94,7 +94,7 @@ type ( // WorkflowDefinition wraps the code that can execute a workflow. workflowDefinition interface { - Execute(env workflowEnvironment, header *commonproto.Header, input []byte) + Execute(env workflowEnvironment, header *commonpb.Header, input []byte) // Called for each non timed out startDecision event. // Executed after all history events since the previous decision are applied to workflowDefinition OnDecisionTaskStarted() diff --git a/internal/internal_worker_interfaces_test.go b/internal/internal_worker_interfaces_test.go index 2b34c58df..0b59eb459 100644 --- a/internal/internal_worker_interfaces_test.go +++ b/internal/internal_worker_interfaces_test.go @@ -31,8 +31,7 @@ import ( "github.com/stretchr/testify/suite" "go.uber.org/zap" - commonproto "go.temporal.io/temporal-proto/common" - "go.temporal.io/temporal-proto/enums" + namespacepb "go.temporal.io/temporal-proto/namespace" "go.temporal.io/temporal-proto/workflowservice" "go.temporal.io/temporal-proto/workflowservicemock" ) @@ -184,9 +183,9 @@ func (s *InterfacesTestSuite) TestInterface() { Tracer: opentracing.NoopTracer{}, } - namespaceStatus := enums.NamespaceStatusRegistered + namespaceStatus := namespacepb.NamespaceStatusRegistered namespaceDesc := &workflowservice.DescribeNamespaceResponse{ - NamespaceInfo: &commonproto.NamespaceInfo{ + NamespaceInfo: &namespacepb.NamespaceInfo{ Name: namespace, Status: namespaceStatus, }, diff --git a/internal/internal_worker_test.go b/internal/internal_worker_test.go index 69436a7be..3e026ff49 100644 --- a/internal/internal_worker_test.go +++ b/internal/internal_worker_test.go @@ -35,9 +35,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - commonproto "go.temporal.io/temporal-proto/common" - "go.temporal.io/temporal-proto/enums" + + commonpb "go.temporal.io/temporal-proto/common" + eventpb "go.temporal.io/temporal-proto/event" + executionpb "go.temporal.io/temporal-proto/execution" + namespacepb "go.temporal.io/temporal-proto/namespace" "go.temporal.io/temporal-proto/serviceerror" + tasklistpb "go.temporal.io/temporal-proto/tasklist" "go.temporal.io/temporal-proto/workflowservice" "go.temporal.io/temporal-proto/workflowservicemock" "go.uber.org/zap" @@ -220,39 +224,39 @@ func testActivity(context.Context) error { func (s *internalWorkerTestSuite) TestReplayWorkflowHistory() { taskList := "taskList1" - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{ - WorkflowType: &commonproto.WorkflowType{Name: "testReplayWorkflow"}, - TaskList: &commonproto.TaskList{Name: taskList}, + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{ + WorkflowType: &commonpb.WorkflowType{Name: "testReplayWorkflow"}, + TaskList: &tasklistpb.TaskList{Name: taskList}, Input: testEncodeFunctionArgs(nil), }), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{}), createTestEventDecisionTaskStarted(3), - createTestEventDecisionTaskCompleted(4, &commonproto.DecisionTaskCompletedEventAttributes{}), - createTestEventActivityTaskScheduled(5, &commonproto.ActivityTaskScheduledEventAttributes{ + createTestEventDecisionTaskCompleted(4, &eventpb.DecisionTaskCompletedEventAttributes{}), + createTestEventActivityTaskScheduled(5, &eventpb.ActivityTaskScheduledEventAttributes{ ActivityId: "0", - ActivityType: &commonproto.ActivityType{Name: "testActivity"}, - TaskList: &commonproto.TaskList{Name: taskList}, + ActivityType: &commonpb.ActivityType{Name: "testActivity"}, + TaskList: &tasklistpb.TaskList{Name: taskList}, }), - createTestEventActivityTaskStarted(6, &commonproto.ActivityTaskStartedEventAttributes{ + createTestEventActivityTaskStarted(6, &eventpb.ActivityTaskStartedEventAttributes{ ScheduledEventId: 5, }), - createTestEventActivityTaskCompleted(7, &commonproto.ActivityTaskCompletedEventAttributes{ + createTestEventActivityTaskCompleted(7, &eventpb.ActivityTaskCompletedEventAttributes{ ScheduledEventId: 5, StartedEventId: 6, }), - createTestEventDecisionTaskScheduled(8, &commonproto.DecisionTaskScheduledEventAttributes{}), + createTestEventDecisionTaskScheduled(8, &eventpb.DecisionTaskScheduledEventAttributes{}), createTestEventDecisionTaskStarted(9), - createTestEventDecisionTaskCompleted(10, &commonproto.DecisionTaskCompletedEventAttributes{ + createTestEventDecisionTaskCompleted(10, &eventpb.DecisionTaskCompletedEventAttributes{ ScheduledEventId: 8, StartedEventId: 9, }), - createTestEventWorkflowExecutionCompleted(11, &commonproto.WorkflowExecutionCompletedEventAttributes{ + createTestEventWorkflowExecutionCompleted(11, &eventpb.WorkflowExecutionCompletedEventAttributes{ DecisionTaskCompletedEventId: 10, }), } - history := &commonproto.History{Events: testEvents} + history := &eventpb.History{Events: testEvents} logger := getLogger() replayer := NewWorkflowReplayer() replayer.RegisterWorkflow(testReplayWorkflow) @@ -262,28 +266,28 @@ func (s *internalWorkerTestSuite) TestReplayWorkflowHistory() { func (s *internalWorkerTestSuite) TestReplayWorkflowHistory_LocalActivity() { taskList := "taskList1" - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{ - WorkflowType: &commonproto.WorkflowType{Name: "testReplayWorkflowLocalActivity"}, - TaskList: &commonproto.TaskList{Name: taskList}, + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{ + WorkflowType: &commonpb.WorkflowType{Name: "testReplayWorkflowLocalActivity"}, + TaskList: &tasklistpb.TaskList{Name: taskList}, Input: testEncodeFunctionArgs(nil), }), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{}), createTestEventDecisionTaskStarted(3), - createTestEventDecisionTaskCompleted(4, &commonproto.DecisionTaskCompletedEventAttributes{}), + createTestEventDecisionTaskCompleted(4, &eventpb.DecisionTaskCompletedEventAttributes{}), - createTestEventLocalActivity(5, &commonproto.MarkerRecordedEventAttributes{ + createTestEventLocalActivity(5, &eventpb.MarkerRecordedEventAttributes{ MarkerName: localActivityMarkerName, Details: s.createLocalActivityMarkerDataForTest("0"), DecisionTaskCompletedEventId: 4, }), - createTestEventWorkflowExecutionCompleted(6, &commonproto.WorkflowExecutionCompletedEventAttributes{ + createTestEventWorkflowExecutionCompleted(6, &eventpb.WorkflowExecutionCompletedEventAttributes{ DecisionTaskCompletedEventId: 4, }), } - history := &commonproto.History{Events: testEvents} + history := &eventpb.History{Events: testEvents} logger := getLogger() replayer := NewWorkflowReplayer() replayer.RegisterWorkflow(testReplayWorkflowLocalActivity) @@ -293,29 +297,29 @@ func (s *internalWorkerTestSuite) TestReplayWorkflowHistory_LocalActivity() { func (s *internalWorkerTestSuite) TestReplayWorkflowHistory_LocalActivity_Result_Mismatch() { taskList := "taskList1" - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{ - WorkflowType: &commonproto.WorkflowType{Name: "testReplayWorkflowLocalActivity"}, - TaskList: &commonproto.TaskList{Name: taskList}, + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{ + WorkflowType: &commonpb.WorkflowType{Name: "testReplayWorkflowLocalActivity"}, + TaskList: &tasklistpb.TaskList{Name: taskList}, Input: testEncodeFunctionArgs(nil), }), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{}), createTestEventDecisionTaskStarted(3), - createTestEventDecisionTaskCompleted(4, &commonproto.DecisionTaskCompletedEventAttributes{}), + createTestEventDecisionTaskCompleted(4, &eventpb.DecisionTaskCompletedEventAttributes{}), - createTestEventLocalActivity(5, &commonproto.MarkerRecordedEventAttributes{ + createTestEventLocalActivity(5, &eventpb.MarkerRecordedEventAttributes{ MarkerName: localActivityMarkerName, Details: s.createLocalActivityMarkerDataForTest("0"), DecisionTaskCompletedEventId: 4, }), - createTestEventWorkflowExecutionCompleted(6, &commonproto.WorkflowExecutionCompletedEventAttributes{ + createTestEventWorkflowExecutionCompleted(6, &eventpb.WorkflowExecutionCompletedEventAttributes{ Result: []byte("some-incorrect-result"), DecisionTaskCompletedEventId: 4, }), } - history := &commonproto.History{Events: testEvents} + history := &eventpb.History{Events: testEvents} logger := getLogger() replayer := NewWorkflowReplayer() replayer.RegisterWorkflow(testReplayWorkflow) @@ -325,29 +329,29 @@ func (s *internalWorkerTestSuite) TestReplayWorkflowHistory_LocalActivity_Result func (s *internalWorkerTestSuite) TestReplayWorkflowHistory_LocalActivity_Activity_Type_Mismatch() { taskList := "taskList1" - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{ - WorkflowType: &commonproto.WorkflowType{Name: "go.temporal.io/temporal/internal.testReplayWorkflow"}, - TaskList: &commonproto.TaskList{Name: taskList}, + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{ + WorkflowType: &commonpb.WorkflowType{Name: "go.temporal.io/temporal/internal.testReplayWorkflow"}, + TaskList: &tasklistpb.TaskList{Name: taskList}, Input: testEncodeFunctionArgs(nil), }), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{}), createTestEventDecisionTaskStarted(3), - createTestEventDecisionTaskCompleted(4, &commonproto.DecisionTaskCompletedEventAttributes{}), + createTestEventDecisionTaskCompleted(4, &eventpb.DecisionTaskCompletedEventAttributes{}), - createTestEventLocalActivity(5, &commonproto.MarkerRecordedEventAttributes{ + createTestEventLocalActivity(5, &eventpb.MarkerRecordedEventAttributes{ MarkerName: localActivityMarkerName, Details: s.createLocalActivityMarkerDataForTest("0"), DecisionTaskCompletedEventId: 4, }), - createTestEventWorkflowExecutionCompleted(6, &commonproto.WorkflowExecutionCompletedEventAttributes{ + createTestEventWorkflowExecutionCompleted(6, &eventpb.WorkflowExecutionCompletedEventAttributes{ Result: []byte("some-incorrect-result"), DecisionTaskCompletedEventId: 4, }), } - history := &commonproto.History{Events: testEvents} + history := &eventpb.History{Events: testEvents} logger := getLogger() replayer := NewWorkflowReplayer() replayer.RegisterWorkflow(testReplayWorkflow) @@ -373,12 +377,12 @@ func (s *internalWorkerTestSuite) TestReplayWorkflowHistoryFromFile() { func (s *internalWorkerTestSuite) testDecisionTaskHandlerHelper(params workerExecutionParameters) { taskList := "taskList1" - testEvents := []*commonproto.HistoryEvent{ - createTestEventWorkflowExecutionStarted(1, &commonproto.WorkflowExecutionStartedEventAttributes{ - TaskList: &commonproto.TaskList{Name: taskList}, + testEvents := []*eventpb.HistoryEvent{ + createTestEventWorkflowExecutionStarted(1, &eventpb.WorkflowExecutionStartedEventAttributes{ + TaskList: &tasklistpb.TaskList{Name: taskList}, Input: testEncodeFunctionArgs(params.DataConverter), }), - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{}), createTestEventDecisionTaskStarted(3), } @@ -387,9 +391,9 @@ func (s *internalWorkerTestSuite) testDecisionTaskHandlerHelper(params workerExe runID := "testRunID" task := &workflowservice.PollForDecisionTaskResponse{ - WorkflowExecution: &commonproto.WorkflowExecution{WorkflowId: workflowID, RunId: runID}, - WorkflowType: &commonproto.WorkflowType{Name: workflowType}, - History: &commonproto.History{Events: testEvents}, + WorkflowExecution: &executionpb.WorkflowExecution{WorkflowId: workflowID, RunId: runID}, + WorkflowType: &commonpb.WorkflowType{Name: workflowType}, + History: &eventpb.History{Events: testEvents}, PreviousStartedEventId: 0, } @@ -554,9 +558,9 @@ func createWorkerWithThrottle( service *workflowservicemock.MockWorkflowServiceClient, activitiesPerSecond float64, dc DataConverter, ) *AggregatedWorker { namespace := "testNamespace" - namespaceStatus := enums.NamespaceStatusRegistered + namespaceStatus := namespacepb.NamespaceStatusRegistered namespaceDesc := &workflowservice.DescribeNamespaceResponse{ - NamespaceInfo: &commonproto.NamespaceInfo{ + NamespaceInfo: &namespacepb.NamespaceInfo{ Name: namespace, Status: namespaceStatus, }, diff --git a/internal/internal_workers_test.go b/internal/internal_workers_test.go index e63f076e7..24c02e2f6 100644 --- a/internal/internal_workers_test.go +++ b/internal/internal_workers_test.go @@ -29,9 +29,13 @@ import ( "github.com/pborman/uuid" log "github.com/sirupsen/logrus" "github.com/stretchr/testify/suite" - commonproto "go.temporal.io/temporal-proto/common" - "go.temporal.io/temporal-proto/enums" + + commonpb "go.temporal.io/temporal-proto/common" + decisionpb "go.temporal.io/temporal-proto/decision" + eventpb "go.temporal.io/temporal-proto/event" + executionpb "go.temporal.io/temporal-proto/execution" "go.temporal.io/temporal-proto/serviceerror" + tasklistpb "go.temporal.io/temporal-proto/tasklist" "go.temporal.io/temporal-proto/workflowservice" "go.temporal.io/temporal-proto/workflowservicemock" "go.uber.org/zap" @@ -137,16 +141,16 @@ func (s *WorkersTestSuite) TestActivityWorkerStop() { pats := &workflowservice.PollForActivityTaskResponse{ TaskToken: []byte("token"), - WorkflowExecution: &commonproto.WorkflowExecution{ + WorkflowExecution: &executionpb.WorkflowExecution{ WorkflowId: "wID", RunId: "rID"}, - ActivityType: &commonproto.ActivityType{Name: "test"}, + ActivityType: &commonpb.ActivityType{Name: "test"}, ActivityId: uuid.New(), ScheduledTimestamp: time.Now().UnixNano(), ScheduleToCloseTimeoutSeconds: 1, StartedTimestamp: time.Now().UnixNano(), StartToCloseTimeoutSeconds: 1, - WorkflowType: &commonproto.WorkflowType{ + WorkflowType: &commonpb.WorkflowType{ Name: "wType", }, WorkflowNamespace: "namespace", @@ -232,58 +236,58 @@ func (s *WorkersTestSuite) TestLongRunningDecisionTask() { } taskList := "long-running-decision-tl" - testEvents := []*commonproto.HistoryEvent{ + testEvents := []*eventpb.HistoryEvent{ { EventId: 1, - EventType: enums.EventTypeWorkflowExecutionStarted, - Attributes: &commonproto.HistoryEvent_WorkflowExecutionStartedEventAttributes{WorkflowExecutionStartedEventAttributes: &commonproto.WorkflowExecutionStartedEventAttributes{ - TaskList: &commonproto.TaskList{Name: taskList}, + EventType: eventpb.EventTypeWorkflowExecutionStarted, + Attributes: &eventpb.HistoryEvent_WorkflowExecutionStartedEventAttributes{WorkflowExecutionStartedEventAttributes: &eventpb.WorkflowExecutionStartedEventAttributes{ + TaskList: &tasklistpb.TaskList{Name: taskList}, ExecutionStartToCloseTimeoutSeconds: 10, TaskStartToCloseTimeoutSeconds: 2, - WorkflowType: &commonproto.WorkflowType{Name: "long-running-decision-workflow-type"}, + WorkflowType: &commonpb.WorkflowType{Name: "long-running-decision-workflow-type"}, }}, }, - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(3), - createTestEventDecisionTaskCompleted(4, &commonproto.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2}), + createTestEventDecisionTaskCompleted(4, &eventpb.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2}), { EventId: 5, - EventType: enums.EventTypeMarkerRecorded, - Attributes: &commonproto.HistoryEvent_MarkerRecordedEventAttributes{MarkerRecordedEventAttributes: &commonproto.MarkerRecordedEventAttributes{ + EventType: eventpb.EventTypeMarkerRecorded, + Attributes: &eventpb.HistoryEvent_MarkerRecordedEventAttributes{MarkerRecordedEventAttributes: &eventpb.MarkerRecordedEventAttributes{ MarkerName: localActivityMarkerName, Details: s.createLocalActivityMarkerDataForTest("0"), DecisionTaskCompletedEventId: 4, }}, }, - createTestEventDecisionTaskScheduled(6, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(6, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(7), - createTestEventDecisionTaskCompleted(8, &commonproto.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2}), + createTestEventDecisionTaskCompleted(8, &eventpb.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2}), { EventId: 9, - EventType: enums.EventTypeMarkerRecorded, - Attributes: &commonproto.HistoryEvent_MarkerRecordedEventAttributes{MarkerRecordedEventAttributes: &commonproto.MarkerRecordedEventAttributes{ + EventType: eventpb.EventTypeMarkerRecorded, + Attributes: &eventpb.HistoryEvent_MarkerRecordedEventAttributes{MarkerRecordedEventAttributes: &eventpb.MarkerRecordedEventAttributes{ MarkerName: localActivityMarkerName, Details: s.createLocalActivityMarkerDataForTest("1"), DecisionTaskCompletedEventId: 8, }}, }, - createTestEventDecisionTaskScheduled(10, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(10, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(11), } s.service.EXPECT().DescribeNamespace(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes() task := &workflowservice.PollForDecisionTaskResponse{ TaskToken: []byte("test-token"), - WorkflowExecution: &commonproto.WorkflowExecution{ + WorkflowExecution: &executionpb.WorkflowExecution{ WorkflowId: "long-running-decision-workflow-id", RunId: "long-running-decision-workflow-run-id", }, - WorkflowType: &commonproto.WorkflowType{ + WorkflowType: &commonpb.WorkflowType{ Name: "long-running-decision-workflow-type", }, PreviousStartedEventId: 0, StartedEventId: 3, - History: &commonproto.History{Events: testEvents[0:3]}, + History: &eventpb.History{Events: testEvents[0:3]}, NextPageToken: nil, } s.service.EXPECT().PollForDecisionTask(gomock.Any(), gomock.Any(), gomock.Any()).Return(task, nil).Times(1) @@ -296,15 +300,15 @@ func (s *WorkersTestSuite) TestLongRunningDecisionTask() { switch respondCounter { case 1: s.Equal(1, len(request.Decisions)) - s.Equal(enums.DecisionTypeRecordMarker, request.Decisions[0].GetDecisionType()) + s.Equal(decisionpb.DecisionTypeRecordMarker, request.Decisions[0].GetDecisionType()) task.PreviousStartedEventId = 3 task.StartedEventId = 7 task.History.Events = testEvents[3:7] return &workflowservice.RespondDecisionTaskCompletedResponse{DecisionTask: task}, nil case 2: s.Equal(2, len(request.Decisions)) - s.Equal(enums.DecisionTypeRecordMarker, request.Decisions[0].GetDecisionType()) - s.Equal(enums.DecisionTypeCompleteWorkflowExecution, request.Decisions[1].GetDecisionType()) + s.Equal(decisionpb.DecisionTypeRecordMarker, request.Decisions[0].GetDecisionType()) + s.Equal(decisionpb.DecisionTypeCompleteWorkflowExecution, request.Decisions[1].GetDecisionType()) task.PreviousStartedEventId = 7 task.StartedEventId = 11 task.History.Events = testEvents[7:11] @@ -372,58 +376,58 @@ func (s *WorkersTestSuite) TestMultipleLocalActivities() { } taskList := "multiple-local-activities-tl" - testEvents := []*commonproto.HistoryEvent{ + testEvents := []*eventpb.HistoryEvent{ { EventId: 1, - EventType: enums.EventTypeWorkflowExecutionStarted, - Attributes: &commonproto.HistoryEvent_WorkflowExecutionStartedEventAttributes{WorkflowExecutionStartedEventAttributes: &commonproto.WorkflowExecutionStartedEventAttributes{ - TaskList: &commonproto.TaskList{Name: taskList}, + EventType: eventpb.EventTypeWorkflowExecutionStarted, + Attributes: &eventpb.HistoryEvent_WorkflowExecutionStartedEventAttributes{WorkflowExecutionStartedEventAttributes: &eventpb.WorkflowExecutionStartedEventAttributes{ + TaskList: &tasklistpb.TaskList{Name: taskList}, ExecutionStartToCloseTimeoutSeconds: 10, TaskStartToCloseTimeoutSeconds: 3, - WorkflowType: &commonproto.WorkflowType{Name: "multiple-local-activities-workflow-type"}, + WorkflowType: &commonpb.WorkflowType{Name: "multiple-local-activities-workflow-type"}, }}, }, - createTestEventDecisionTaskScheduled(2, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(2, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(3), - createTestEventDecisionTaskCompleted(4, &commonproto.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2}), + createTestEventDecisionTaskCompleted(4, &eventpb.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2}), { EventId: 5, - EventType: enums.EventTypeMarkerRecorded, - Attributes: &commonproto.HistoryEvent_MarkerRecordedEventAttributes{MarkerRecordedEventAttributes: &commonproto.MarkerRecordedEventAttributes{ + EventType: eventpb.EventTypeMarkerRecorded, + Attributes: &eventpb.HistoryEvent_MarkerRecordedEventAttributes{MarkerRecordedEventAttributes: &eventpb.MarkerRecordedEventAttributes{ MarkerName: localActivityMarkerName, Details: s.createLocalActivityMarkerDataForTest("0"), DecisionTaskCompletedEventId: 4, }}, }, - createTestEventDecisionTaskScheduled(6, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(6, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(7), - createTestEventDecisionTaskCompleted(8, &commonproto.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2}), + createTestEventDecisionTaskCompleted(8, &eventpb.DecisionTaskCompletedEventAttributes{ScheduledEventId: 2}), { EventId: 9, - EventType: enums.EventTypeMarkerRecorded, - Attributes: &commonproto.HistoryEvent_MarkerRecordedEventAttributes{MarkerRecordedEventAttributes: &commonproto.MarkerRecordedEventAttributes{ + EventType: eventpb.EventTypeMarkerRecorded, + Attributes: &eventpb.HistoryEvent_MarkerRecordedEventAttributes{MarkerRecordedEventAttributes: &eventpb.MarkerRecordedEventAttributes{ MarkerName: localActivityMarkerName, Details: s.createLocalActivityMarkerDataForTest("1"), DecisionTaskCompletedEventId: 8, }}, }, - createTestEventDecisionTaskScheduled(10, &commonproto.DecisionTaskScheduledEventAttributes{TaskList: &commonproto.TaskList{Name: taskList}}), + createTestEventDecisionTaskScheduled(10, &eventpb.DecisionTaskScheduledEventAttributes{TaskList: &tasklistpb.TaskList{Name: taskList}}), createTestEventDecisionTaskStarted(11), } s.service.EXPECT().DescribeNamespace(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes() task := &workflowservice.PollForDecisionTaskResponse{ TaskToken: []byte("test-token"), - WorkflowExecution: &commonproto.WorkflowExecution{ + WorkflowExecution: &executionpb.WorkflowExecution{ WorkflowId: "multiple-local-activities-workflow-id", RunId: "multiple-local-activities-workflow-run-id", }, - WorkflowType: &commonproto.WorkflowType{ + WorkflowType: &commonpb.WorkflowType{ Name: "multiple-local-activities-workflow-type", }, PreviousStartedEventId: 0, StartedEventId: 3, - History: &commonproto.History{Events: testEvents[0:3]}, + History: &eventpb.History{Events: testEvents[0:3]}, NextPageToken: nil, } s.service.EXPECT().PollForDecisionTask(gomock.Any(), gomock.Any(), gomock.Any()).Return(task, nil).Times(1) @@ -436,7 +440,7 @@ func (s *WorkersTestSuite) TestMultipleLocalActivities() { switch respondCounter { case 1: s.Equal(3, len(request.Decisions)) - s.Equal(enums.DecisionTypeRecordMarker, request.Decisions[0].GetDecisionType()) + s.Equal(decisionpb.DecisionTypeRecordMarker, request.Decisions[0].GetDecisionType()) task.PreviousStartedEventId = 3 task.StartedEventId = 7 task.History.Events = testEvents[3:11] diff --git a/internal/internal_workflow.go b/internal/internal_workflow.go index 8368da424..6ec97f8b9 100644 --- a/internal/internal_workflow.go +++ b/internal/internal_workflow.go @@ -36,7 +36,7 @@ import ( "go.uber.org/atomic" "go.uber.org/zap" - commonproto "go.temporal.io/temporal-proto/common" + commonpb "go.temporal.io/temporal-proto/common" "go.temporal.io/temporal/internal/common/metrics" ) @@ -175,7 +175,7 @@ type ( queryHandlers map[string]func([]byte) ([]byte, error) workflowIDReusePolicy WorkflowIDReusePolicy dataConverter DataConverter - retryPolicy *commonproto.RetryPolicy + retryPolicy *commonpb.RetryPolicy cronSchedule string contextPropagators []ContextPropagator memo map[string]interface{} @@ -187,7 +187,7 @@ type ( workflowOptions workflowType *WorkflowType input []byte - header *commonproto.Header + header *commonpb.Header attempt int32 // used by test framework to support child workflow retry scheduledTime time.Time // used by test framework to support child workflow retry lastCompletionResult []byte // used by test framework to support cron @@ -445,7 +445,7 @@ func newWorkflowInterceptors(env workflowEnvironment, factories []WorkflowInterc return interceptor, envInterceptor } -func (d *syncWorkflowDefinition) Execute(env workflowEnvironment, header *commonproto.Header, input []byte) { +func (d *syncWorkflowDefinition) Execute(env workflowEnvironment, header *commonpb.Header, input []byte) { interceptors, envInterceptor := newWorkflowInterceptors(env, env.GetRegistry().getInterceptors()) dispatcher, rootCtx := newDispatcher(newWorkflowContext(env, interceptors, envInterceptor), func(ctx Context) { r := &workflowResult{} @@ -1230,8 +1230,8 @@ func getContextPropagatorsFromWorkflowContext(ctx Context) []ContextPropagator { return options.contextPropagators } -func getHeadersFromContext(ctx Context) *commonproto.Header { - header := &commonproto.Header{ +func getHeadersFromContext(ctx Context) *commonpb.Header { + header := &commonpb.Header{ Fields: make(map[string][]byte), } contextPropagators := getContextPropagatorsFromWorkflowContext(ctx) diff --git a/internal/internal_workflow_client.go b/internal/internal_workflow_client.go index 3c305a0ed..3e3489bc4 100644 --- a/internal/internal_workflow_client.go +++ b/internal/internal_workflow_client.go @@ -32,9 +32,14 @@ import ( "github.com/opentracing/opentracing-go" "github.com/pborman/uuid" "github.com/uber-go/tally" - commonproto "go.temporal.io/temporal-proto/common" - "go.temporal.io/temporal-proto/enums" + + commonpb "go.temporal.io/temporal-proto/common" + eventpb "go.temporal.io/temporal-proto/event" + executionpb "go.temporal.io/temporal-proto/execution" + filterpb "go.temporal.io/temporal-proto/filter" + querypb "go.temporal.io/temporal-proto/query" "go.temporal.io/temporal-proto/serviceerror" + tasklistpb "go.temporal.io/temporal-proto/tasklist" "go.temporal.io/temporal-proto/workflowservice" "go.temporal.io/temporal/internal/common" @@ -120,7 +125,7 @@ type ( // - EntityNotExistsError // - BadRequestError // - InternalServiceError - Next() (*commonproto.HistoryEvent, error) + Next() (*eventpb.HistoryEvent, error) } // historyEventIteratorImpl is the implementation of HistoryEventIterator @@ -129,7 +134,7 @@ type ( initialized bool // local cached histroy events and corresponding comsuming index nextEventIndex int - events []*commonproto.HistoryEvent + events []*eventpb.HistoryEvent // token to get next page of history events nexttoken []byte // err when getting next page of history events @@ -209,8 +214,8 @@ func (wc *WorkflowClient) StartWorkflow( Namespace: wc.namespace, RequestId: uuid.New(), WorkflowId: workflowID, - WorkflowType: &commonproto.WorkflowType{Name: workflowType.Name}, - TaskList: &commonproto.TaskList{Name: options.TaskList}, + WorkflowType: &commonpb.WorkflowType{Name: workflowType.Name}, + TaskList: &tasklistpb.TaskList{Name: options.TaskList}, Input: input, ExecutionStartToCloseTimeoutSeconds: executionTimeout, TaskStartToCloseTimeoutSeconds: decisionTaskTimeout, @@ -280,7 +285,7 @@ func (wc *WorkflowClient) ExecuteWorkflow(ctx context.Context, options StartWork } iterFn := func(fnCtx context.Context, fnRunID string) HistoryEventIterator { - return wc.GetWorkflowHistory(fnCtx, workflowID, fnRunID, true, enums.HistoryEventFilterTypeCloseEvent) + return wc.GetWorkflowHistory(fnCtx, workflowID, fnRunID, true, filterpb.HistoryEventFilterTypeCloseEvent) } return &workflowRunImpl{ @@ -301,7 +306,7 @@ func (wc *WorkflowClient) ExecuteWorkflow(ctx context.Context, options StartWork func (wc *WorkflowClient) GetWorkflow(_ context.Context, workflowID string, runID string) WorkflowRun { iterFn := func(fnCtx context.Context, fnRunID string) HistoryEventIterator { - return wc.GetWorkflowHistory(fnCtx, workflowID, fnRunID, true, enums.HistoryEventFilterTypeCloseEvent) + return wc.GetWorkflowHistory(fnCtx, workflowID, fnRunID, true, filterpb.HistoryEventFilterTypeCloseEvent) } return &workflowRunImpl{ @@ -323,7 +328,7 @@ func (wc *WorkflowClient) SignalWorkflow(ctx context.Context, workflowID string, request := &workflowservice.SignalWorkflowExecutionRequest{ Namespace: wc.namespace, - WorkflowExecution: &commonproto.WorkflowExecution{ + WorkflowExecution: &executionpb.WorkflowExecution{ WorkflowId: workflowID, RunId: runID, }, @@ -399,8 +404,8 @@ func (wc *WorkflowClient) SignalWithStartWorkflow(ctx context.Context, workflowI Namespace: wc.namespace, RequestId: uuid.New(), WorkflowId: workflowID, - WorkflowType: &commonproto.WorkflowType{Name: workflowType.Name}, - TaskList: &commonproto.TaskList{Name: options.TaskList}, + WorkflowType: &commonpb.WorkflowType{Name: workflowType.Name}, + TaskList: &tasklistpb.TaskList{Name: options.TaskList}, Input: input, ExecutionStartToCloseTimeoutSeconds: executionTimeout, TaskStartToCloseTimeoutSeconds: decisionTaskTimeout, @@ -449,7 +454,7 @@ func (wc *WorkflowClient) SignalWithStartWorkflow(ctx context.Context, workflowI func (wc *WorkflowClient) CancelWorkflow(ctx context.Context, workflowID string, runID string) error { request := &workflowservice.RequestCancelWorkflowExecutionRequest{ Namespace: wc.namespace, - WorkflowExecution: &commonproto.WorkflowExecution{ + WorkflowExecution: &executionpb.WorkflowExecution{ WorkflowId: workflowID, RunId: runID, }, @@ -471,7 +476,7 @@ func (wc *WorkflowClient) CancelWorkflow(ctx context.Context, workflowID string, func (wc *WorkflowClient) TerminateWorkflow(ctx context.Context, workflowID string, runID string, reason string, details []byte) error { request := &workflowservice.TerminateWorkflowExecutionRequest{ Namespace: wc.namespace, - WorkflowExecution: &commonproto.WorkflowExecution{ + WorkflowExecution: &executionpb.WorkflowExecution{ WorkflowId: workflowID, RunId: runID, }, @@ -493,13 +498,13 @@ func (wc *WorkflowClient) TerminateWorkflow(ctx context.Context, workflowID stri // GetWorkflowHistory return a channel which contains the history events of a given workflow func (wc *WorkflowClient) GetWorkflowHistory(ctx context.Context, workflowID string, runID string, - isLongPoll bool, filterType enums.HistoryEventFilterType) HistoryEventIterator { + isLongPoll bool, filterType filterpb.HistoryEventFilterType) HistoryEventIterator { namespace := wc.namespace paginate := func(nexttoken []byte) (*workflowservice.GetWorkflowExecutionHistoryResponse, error) { request := &workflowservice.GetWorkflowExecutionHistoryRequest{ Namespace: namespace, - Execution: &commonproto.WorkflowExecution{ + Execution: &executionpb.WorkflowExecution{ WorkflowId: workflowID, RunId: runID, }, @@ -770,7 +775,7 @@ func (wc *WorkflowClient) GetSearchAttributes(ctx context.Context) (*workflowser func (wc *WorkflowClient) DescribeWorkflowExecution(ctx context.Context, workflowID, runID string) (*workflowservice.DescribeWorkflowExecutionResponse, error) { request := &workflowservice.DescribeWorkflowExecutionRequest{ Namespace: wc.namespace, - Execution: &commonproto.WorkflowExecution{ + Execution: &executionpb.WorkflowExecution{ WorkflowId: workflowID, RunId: runID, }, @@ -837,12 +842,12 @@ type QueryWorkflowWithOptionsRequest struct { // QueryRejectCondition is an optional field used to reject queries based on workflow state. // QueryRejectConditionNotOpen will reject queries to workflows which are not open // QueryRejectConditionNotCompletedCleanly will reject queries to workflows which completed in any state other than completed (e.g. terminated, canceled timeout etc...) - QueryRejectCondition enums.QueryRejectCondition + QueryRejectCondition querypb.QueryRejectCondition // QueryConsistencyLevel is an optional field used to control the consistency level. // QueryConsistencyLevelEventual means that query will eventually reflect up to date state of a workflow. // QueryConsistencyLevelStrong means that query will reflect a workflow state of having applied all events which came before the query. - QueryConsistencyLevel enums.QueryConsistencyLevel + QueryConsistencyLevel querypb.QueryConsistencyLevel } // QueryWorkflowWithOptionsResponse is the response to QueryWorkflowWithOptions @@ -852,7 +857,7 @@ type QueryWorkflowWithOptionsResponse struct { QueryResult Value // QueryRejected contains information about the query rejection. - QueryRejected *commonproto.QueryRejected + QueryRejected *querypb.QueryRejected } // QueryWorkflowWithOptions queries a given workflow execution and returns the query result synchronously. @@ -872,11 +877,11 @@ func (wc *WorkflowClient) QueryWorkflowWithOptions(ctx context.Context, request } req := &workflowservice.QueryWorkflowRequest{ Namespace: wc.namespace, - Execution: &commonproto.WorkflowExecution{ + Execution: &executionpb.WorkflowExecution{ WorkflowId: request.WorkflowID, RunId: request.RunID, }, - Query: &commonproto.WorkflowQuery{ + Query: &querypb.WorkflowQuery{ QueryType: request.QueryType, QueryArgs: input, }, @@ -917,10 +922,10 @@ func (wc *WorkflowClient) QueryWorkflowWithOptions(ctx context.Context, request // - BadRequestError // - InternalServiceError // - EntityNotExistError -func (wc *WorkflowClient) DescribeTaskList(ctx context.Context, taskList string, taskListType enums.TaskListType) (*workflowservice.DescribeTaskListResponse, error) { +func (wc *WorkflowClient) DescribeTaskList(ctx context.Context, taskList string, taskListType tasklistpb.TaskListType) (*workflowservice.DescribeTaskListResponse, error) { request := &workflowservice.DescribeTaskListRequest{ Namespace: wc.namespace, - TaskList: &commonproto.TaskList{Name: taskList}, + TaskList: &tasklistpb.TaskList{Name: taskList}, TaskListType: taskListType, } @@ -949,8 +954,8 @@ func (wc *WorkflowClient) CloseConnection() error { return wc.connectionCloser.Close() } -func (wc *WorkflowClient) getWorkflowHeader(ctx context.Context) *commonproto.Header { - header := &commonproto.Header{ +func (wc *WorkflowClient) getWorkflowHeader(ctx context.Context) *commonpb.Header { + header := &commonpb.Header{ Fields: make(map[string][]byte), } writer := NewHeaderWriter(header) @@ -1054,7 +1059,7 @@ func (iter *historyEventIteratorImpl) HasNext() bool { return false } -func (iter *historyEventIteratorImpl) Next() (*commonproto.HistoryEvent, error) { +func (iter *historyEventIteratorImpl) Next() (*eventpb.HistoryEvent, error) { // if caller call the Next() when iteration is over, just return nil, nil if !iter.HasNext() { panic("HistoryEventIterator Next() called without checking HasNext()") @@ -1095,7 +1100,7 @@ func (workflowRun *workflowRunImpl) Get(ctx context.Context, valuePtr interface{ } switch closeEvent.GetEventType() { - case enums.EventTypeWorkflowExecutionCompleted: + case eventpb.EventTypeWorkflowExecutionCompleted: attributes := closeEvent.GetWorkflowExecutionCompletedEventAttributes() if valuePtr == nil || attributes.Result == nil { return nil @@ -1105,19 +1110,19 @@ func (workflowRun *workflowRunImpl) Get(ctx context.Context, valuePtr interface{ return errors.New("value parameter is not a pointer") } err = deSerializeFunctionResult(workflowRun.workflowFn, attributes.Result, valuePtr, workflowRun.dataConverter, workflowRun.registry) - case enums.EventTypeWorkflowExecutionFailed: + case eventpb.EventTypeWorkflowExecutionFailed: attributes := closeEvent.GetWorkflowExecutionFailedEventAttributes() err = constructError(attributes.GetReason(), attributes.Details, workflowRun.dataConverter) - case enums.EventTypeWorkflowExecutionCanceled: + case eventpb.EventTypeWorkflowExecutionCanceled: attributes := closeEvent.GetWorkflowExecutionCanceledEventAttributes() details := newEncodedValues(attributes.Details, workflowRun.dataConverter) err = NewCanceledError(details) - case enums.EventTypeWorkflowExecutionTerminated: + case eventpb.EventTypeWorkflowExecutionTerminated: err = newTerminatedError() - case enums.EventTypeWorkflowExecutionTimedOut: + case eventpb.EventTypeWorkflowExecutionTimedOut: attributes := closeEvent.GetWorkflowExecutionTimedOutEventAttributes() err = NewTimeoutError(attributes.GetTimeoutType()) - case enums.EventTypeWorkflowExecutionContinuedAsNew: + case eventpb.EventTypeWorkflowExecutionContinuedAsNew: attributes := closeEvent.GetWorkflowExecutionContinuedAsNewEventAttributes() workflowRun.currentRunID = attributes.GetNewExecutionRunId() return workflowRun.Get(ctx, valuePtr) @@ -1127,7 +1132,7 @@ func (workflowRun *workflowRunImpl) Get(ctx context.Context, valuePtr interface{ return err } -func getWorkflowMemo(input map[string]interface{}, dc DataConverter) (*commonproto.Memo, error) { +func getWorkflowMemo(input map[string]interface{}, dc DataConverter) (*commonpb.Memo, error) { if input == nil { return nil, nil } @@ -1140,10 +1145,10 @@ func getWorkflowMemo(input map[string]interface{}, dc DataConverter) (*commonpro } memo[k] = memoBytes } - return &commonproto.Memo{Fields: memo}, nil + return &commonpb.Memo{Fields: memo}, nil } -func serializeSearchAttributes(input map[string]interface{}) (*commonproto.SearchAttributes, error) { +func serializeSearchAttributes(input map[string]interface{}) (*commonpb.SearchAttributes, error) { if input == nil { return nil, nil } @@ -1156,5 +1161,5 @@ func serializeSearchAttributes(input map[string]interface{}) (*commonproto.Searc } attr[k] = attrBytes } - return &commonproto.SearchAttributes{IndexedFields: attr}, nil + return &commonpb.SearchAttributes{IndexedFields: attr}, nil } diff --git a/internal/internal_workflow_client_test.go b/internal/internal_workflow_client_test.go index d161d93b2..1375e819e 100644 --- a/internal/internal_workflow_client_test.go +++ b/internal/internal_workflow_client_test.go @@ -31,8 +31,10 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" - commonproto "go.temporal.io/temporal-proto/common" - "go.temporal.io/temporal-proto/enums" + + eventpb "go.temporal.io/temporal-proto/event" + executionpb "go.temporal.io/temporal-proto/execution" + filterpb "go.temporal.io/temporal-proto/filter" "go.temporal.io/temporal-proto/serviceerror" "go.temporal.io/temporal-proto/workflowservice" "go.temporal.io/temporal-proto/workflowservicemock" @@ -155,11 +157,11 @@ func (s *historyEventIteratorSuite) TearDownTest() { } func (s *historyEventIteratorSuite) TestIterator_NoError() { - filterType := enums.HistoryEventFilterTypeAllEvent + filterType := filterpb.HistoryEventFilterTypeAllEvent request1 := getGetWorkflowExecutionHistoryRequest(filterType) response1 := &workflowservice.GetWorkflowExecutionHistoryResponse{ - History: &commonproto.History{ - Events: []*commonproto.HistoryEvent{ + History: &eventpb.History{ + Events: []*eventpb.HistoryEvent{ // dummy history event {}, }, @@ -169,8 +171,8 @@ func (s *historyEventIteratorSuite) TestIterator_NoError() { request2 := getGetWorkflowExecutionHistoryRequest(filterType) request2.NextPageToken = response1.NextPageToken response2 := &workflowservice.GetWorkflowExecutionHistoryResponse{ - History: &commonproto.History{ - Events: []*commonproto.HistoryEvent{ + History: &eventpb.History{ + Events: []*eventpb.HistoryEvent{ // dummy history event {}, }, @@ -181,8 +183,8 @@ func (s *historyEventIteratorSuite) TestIterator_NoError() { s.workflowServiceClient.EXPECT().GetWorkflowExecutionHistory(gomock.Any(), request1, gomock.Any()).Return(response1, nil).Times(1) s.workflowServiceClient.EXPECT().GetWorkflowExecutionHistory(gomock.Any(), request2, gomock.Any()).Return(response2, nil).Times(1) - var events []*commonproto.HistoryEvent - iter := s.wfClient.GetWorkflowHistory(context.Background(), workflowID, runID, true, enums.HistoryEventFilterTypeAllEvent) + var events []*eventpb.HistoryEvent + iter := s.wfClient.GetWorkflowHistory(context.Background(), workflowID, runID, true, filterpb.HistoryEventFilterTypeAllEvent) for iter.HasNext() { event, err := iter.Next() s.Nil(err) @@ -192,19 +194,19 @@ func (s *historyEventIteratorSuite) TestIterator_NoError() { } func (s *historyEventIteratorSuite) TestIterator_NoError_EmptyPage() { - filterType := enums.HistoryEventFilterTypeAllEvent + filterType := filterpb.HistoryEventFilterTypeAllEvent request1 := getGetWorkflowExecutionHistoryRequest(filterType) response1 := &workflowservice.GetWorkflowExecutionHistoryResponse{ - History: &commonproto.History{ - Events: []*commonproto.HistoryEvent{}, + History: &eventpb.History{ + Events: []*eventpb.HistoryEvent{}, }, NextPageToken: []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, } request2 := getGetWorkflowExecutionHistoryRequest(filterType) request2.NextPageToken = response1.NextPageToken response2 := &workflowservice.GetWorkflowExecutionHistoryResponse{ - History: &commonproto.History{ - Events: []*commonproto.HistoryEvent{ + History: &eventpb.History{ + Events: []*eventpb.HistoryEvent{ // dummy history event {}, }, @@ -215,8 +217,8 @@ func (s *historyEventIteratorSuite) TestIterator_NoError_EmptyPage() { s.workflowServiceClient.EXPECT().GetWorkflowExecutionHistory(gomock.Any(), request1, gomock.Any()).Return(response1, nil).Times(1) s.workflowServiceClient.EXPECT().GetWorkflowExecutionHistory(gomock.Any(), request2, gomock.Any()).Return(response2, nil).Times(1) - var events []*commonproto.HistoryEvent - iter := s.wfClient.GetWorkflowHistory(context.Background(), workflowID, runID, true, enums.HistoryEventFilterTypeAllEvent) + var events []*eventpb.HistoryEvent + iter := s.wfClient.GetWorkflowHistory(context.Background(), workflowID, runID, true, filterpb.HistoryEventFilterTypeAllEvent) for iter.HasNext() { event, err := iter.Next() s.Nil(err) @@ -226,11 +228,11 @@ func (s *historyEventIteratorSuite) TestIterator_NoError_EmptyPage() { } func (s *historyEventIteratorSuite) TestIterator_Error() { - filterType := enums.HistoryEventFilterTypeAllEvent + filterType := filterpb.HistoryEventFilterTypeAllEvent request1 := getGetWorkflowExecutionHistoryRequest(filterType) response1 := &workflowservice.GetWorkflowExecutionHistoryResponse{ - History: &commonproto.History{ - Events: []*commonproto.HistoryEvent{ + History: &eventpb.History{ + Events: []*eventpb.HistoryEvent{ // dummy history event {}, }, @@ -242,7 +244,7 @@ func (s *historyEventIteratorSuite) TestIterator_Error() { s.workflowServiceClient.EXPECT().GetWorkflowExecutionHistory(gomock.Any(), request1, gomock.Any()).Return(response1, nil).Times(1) - iter := s.wfClient.GetWorkflowHistory(context.Background(), workflowID, runID, true, enums.HistoryEventFilterTypeAllEvent) + iter := s.wfClient.GetWorkflowHistory(context.Background(), workflowID, runID, true, filterpb.HistoryEventFilterTypeAllEvent) s.True(iter.HasNext()) event, err := iter.Next() @@ -306,17 +308,17 @@ func (s *workflowRunSuite) TestExecuteWorkflow_NoDup_Success() { } s.workflowServiceClient.EXPECT().StartWorkflowExecution(gomock.Any(), gomock.Any()).Return(createResponse, nil).Times(1) - filterType := enums.HistoryEventFilterTypeCloseEvent - eventType := enums.EventTypeWorkflowExecutionCompleted + filterType := filterpb.HistoryEventFilterTypeCloseEvent + eventType := eventpb.EventTypeWorkflowExecutionCompleted workflowResult := time.Hour * 59 encodedResult, _ := encodeArg(getDefaultDataConverter(), workflowResult) getRequest := getGetWorkflowExecutionHistoryRequest(filterType) getResponse := &workflowservice.GetWorkflowExecutionHistoryResponse{ - History: &commonproto.History{ - Events: []*commonproto.HistoryEvent{ + History: &eventpb.History{ + Events: []*eventpb.HistoryEvent{ { EventType: eventType, - Attributes: &commonproto.HistoryEvent_WorkflowExecutionCompletedEventAttributes{WorkflowExecutionCompletedEventAttributes: &commonproto.WorkflowExecutionCompletedEventAttributes{ + Attributes: &eventpb.HistoryEvent_WorkflowExecutionCompletedEventAttributes{WorkflowExecutionCompletedEventAttributes: &eventpb.WorkflowExecutionCompletedEventAttributes{ Result: encodedResult, }}, }, @@ -349,15 +351,15 @@ func (s *workflowRunSuite) TestExecuteWorkflowWorkflowExecutionAlreadyStartedErr s.workflowServiceClient.EXPECT().StartWorkflowExecution(gomock.Any(), gomock.Any(), gomock.Any()). Return(nil, serviceerror.NewWorkflowExecutionAlreadyStarted("Already Started", "", runID)).Times(1) - eventType := enums.EventTypeWorkflowExecutionCompleted + eventType := eventpb.EventTypeWorkflowExecutionCompleted workflowResult := time.Hour * 59 encodedResult, _ := encodeArg(nil, workflowResult) getResponse := &workflowservice.GetWorkflowExecutionHistoryResponse{ - History: &commonproto.History{ - Events: []*commonproto.HistoryEvent{ + History: &eventpb.History{ + Events: []*eventpb.HistoryEvent{ { EventType: eventType, - Attributes: &commonproto.HistoryEvent_WorkflowExecutionCompletedEventAttributes{WorkflowExecutionCompletedEventAttributes: &commonproto.WorkflowExecutionCompletedEventAttributes{ + Attributes: &eventpb.HistoryEvent_WorkflowExecutionCompletedEventAttributes{WorkflowExecutionCompletedEventAttributes: &eventpb.WorkflowExecutionCompletedEventAttributes{ Result: encodedResult, }}, }, @@ -399,15 +401,15 @@ func (s *workflowRunSuite) TestExecuteWorkflow_NoIdInOptions() { } s.workflowServiceClient.EXPECT().StartWorkflowExecution(gomock.Any(), gomock.Any(), gomock.Any()).Return(createResponse, nil).Times(1) - eventType := enums.EventTypeWorkflowExecutionCompleted + eventType := eventpb.EventTypeWorkflowExecutionCompleted workflowResult := time.Hour * 59 encodedResult, _ := encodeArg(nil, workflowResult) getResponse := &workflowservice.GetWorkflowExecutionHistoryResponse{ - History: &commonproto.History{ - Events: []*commonproto.HistoryEvent{ + History: &eventpb.History{ + Events: []*eventpb.HistoryEvent{ { EventType: eventType, - Attributes: &commonproto.HistoryEvent_WorkflowExecutionCompletedEventAttributes{WorkflowExecutionCompletedEventAttributes: &commonproto.WorkflowExecutionCompletedEventAttributes{ + Attributes: &eventpb.HistoryEvent_WorkflowExecutionCompletedEventAttributes{WorkflowExecutionCompletedEventAttributes: &eventpb.WorkflowExecutionCompletedEventAttributes{ Result: encodedResult, }}, }, @@ -446,17 +448,17 @@ func (s *workflowRunSuite) TestExecuteWorkflow_NoDup_Cancelled() { } s.workflowServiceClient.EXPECT().StartWorkflowExecution(gomock.Any(), gomock.Any(), gomock.Any()).Return(createResponse, nil).Times(1) - filterType := enums.HistoryEventFilterTypeCloseEvent - eventType := enums.EventTypeWorkflowExecutionCanceled + filterType := filterpb.HistoryEventFilterTypeCloseEvent + eventType := eventpb.EventTypeWorkflowExecutionCanceled details := "some details" encodedDetails, _ := encodeArg(getDefaultDataConverter(), details) getRequest := getGetWorkflowExecutionHistoryRequest(filterType) getResponse := &workflowservice.GetWorkflowExecutionHistoryResponse{ - History: &commonproto.History{ - Events: []*commonproto.HistoryEvent{ + History: &eventpb.History{ + Events: []*eventpb.HistoryEvent{ { EventType: eventType, - Attributes: &commonproto.HistoryEvent_WorkflowExecutionCanceledEventAttributes{WorkflowExecutionCanceledEventAttributes: &commonproto.WorkflowExecutionCanceledEventAttributes{ + Attributes: &eventpb.HistoryEvent_WorkflowExecutionCanceledEventAttributes{WorkflowExecutionCanceledEventAttributes: &eventpb.WorkflowExecutionCanceledEventAttributes{ Details: encodedDetails, }}, }, @@ -493,19 +495,19 @@ func (s *workflowRunSuite) TestExecuteWorkflow_NoDup_Failed() { } s.workflowServiceClient.EXPECT().StartWorkflowExecution(gomock.Any(), gomock.Any(), gomock.Any()).Return(createResponse, nil).Times(1) - filterType := enums.HistoryEventFilterTypeCloseEvent - eventType := enums.EventTypeWorkflowExecutionFailed + filterType := filterpb.HistoryEventFilterTypeCloseEvent + eventType := eventpb.EventTypeWorkflowExecutionFailed reason := "some reason" details := "some details" dataConverter := getDefaultDataConverter() encodedDetails, _ := encodeArg(dataConverter, details) getRequest := getGetWorkflowExecutionHistoryRequest(filterType) getResponse := &workflowservice.GetWorkflowExecutionHistoryResponse{ - History: &commonproto.History{ - Events: []*commonproto.HistoryEvent{ + History: &eventpb.History{ + Events: []*eventpb.HistoryEvent{ { EventType: eventType, - Attributes: &commonproto.HistoryEvent_WorkflowExecutionFailedEventAttributes{WorkflowExecutionFailedEventAttributes: &commonproto.WorkflowExecutionFailedEventAttributes{ + Attributes: &eventpb.HistoryEvent_WorkflowExecutionFailedEventAttributes{WorkflowExecutionFailedEventAttributes: &eventpb.WorkflowExecutionFailedEventAttributes{ Reason: reason, Details: encodedDetails, }}, @@ -541,15 +543,15 @@ func (s *workflowRunSuite) TestExecuteWorkflow_NoDup_Terminated() { } s.workflowServiceClient.EXPECT().StartWorkflowExecution(gomock.Any(), gomock.Any(), gomock.Any()).Return(createResponse, nil).Times(1) - filterType := enums.HistoryEventFilterTypeCloseEvent - eventType := enums.EventTypeWorkflowExecutionTerminated + filterType := filterpb.HistoryEventFilterTypeCloseEvent + eventType := eventpb.EventTypeWorkflowExecutionTerminated getRequest := getGetWorkflowExecutionHistoryRequest(filterType) getResponse := &workflowservice.GetWorkflowExecutionHistoryResponse{ - History: &commonproto.History{ - Events: []*commonproto.HistoryEvent{ + History: &eventpb.History{ + Events: []*eventpb.HistoryEvent{ { EventType: eventType, - Attributes: &commonproto.HistoryEvent_WorkflowExecutionTerminatedEventAttributes{WorkflowExecutionTerminatedEventAttributes: &commonproto.WorkflowExecutionTerminatedEventAttributes{}}}, + Attributes: &eventpb.HistoryEvent_WorkflowExecutionTerminatedEventAttributes{WorkflowExecutionTerminatedEventAttributes: &eventpb.WorkflowExecutionTerminatedEventAttributes{}}}, }, }, NextPageToken: nil, @@ -581,16 +583,16 @@ func (s *workflowRunSuite) TestExecuteWorkflow_NoDup_TimedOut() { } s.workflowServiceClient.EXPECT().StartWorkflowExecution(gomock.Any(), gomock.Any(), gomock.Any()).Return(createResponse, nil).Times(1) - filterType := enums.HistoryEventFilterTypeCloseEvent - eventType := enums.EventTypeWorkflowExecutionTimedOut - timeType := enums.TimeoutTypeScheduleToStart + filterType := filterpb.HistoryEventFilterTypeCloseEvent + eventType := eventpb.EventTypeWorkflowExecutionTimedOut + timeType := eventpb.TimeoutTypeScheduleToStart getRequest := getGetWorkflowExecutionHistoryRequest(filterType) getResponse := &workflowservice.GetWorkflowExecutionHistoryResponse{ - History: &commonproto.History{ - Events: []*commonproto.HistoryEvent{ + History: &eventpb.History{ + Events: []*eventpb.HistoryEvent{ { EventType: eventType, - Attributes: &commonproto.HistoryEvent_WorkflowExecutionTimedOutEventAttributes{WorkflowExecutionTimedOutEventAttributes: &commonproto.WorkflowExecutionTimedOutEventAttributes{ + Attributes: &eventpb.HistoryEvent_WorkflowExecutionTimedOutEventAttributes{WorkflowExecutionTimedOutEventAttributes: &eventpb.WorkflowExecutionTimedOutEventAttributes{ TimeoutType: timeType, }}, }, @@ -629,15 +631,15 @@ func (s *workflowRunSuite) TestExecuteWorkflow_NoDup_ContinueAsNew() { s.workflowServiceClient.EXPECT().StartWorkflowExecution(gomock.Any(), gomock.Any(), gomock.Any()).Return(createResponse, nil).Times(1) newRunID := "some other random run ID" - filterType := enums.HistoryEventFilterTypeCloseEvent - eventType1 := enums.EventTypeWorkflowExecutionContinuedAsNew + filterType := filterpb.HistoryEventFilterTypeCloseEvent + eventType1 := eventpb.EventTypeWorkflowExecutionContinuedAsNew getRequest1 := getGetWorkflowExecutionHistoryRequest(filterType) getResponse1 := &workflowservice.GetWorkflowExecutionHistoryResponse{ - History: &commonproto.History{ - Events: []*commonproto.HistoryEvent{ + History: &eventpb.History{ + Events: []*eventpb.HistoryEvent{ { EventType: eventType1, - Attributes: &commonproto.HistoryEvent_WorkflowExecutionContinuedAsNewEventAttributes{WorkflowExecutionContinuedAsNewEventAttributes: &commonproto.WorkflowExecutionContinuedAsNewEventAttributes{ + Attributes: &eventpb.HistoryEvent_WorkflowExecutionContinuedAsNewEventAttributes{WorkflowExecutionContinuedAsNewEventAttributes: &eventpb.WorkflowExecutionContinuedAsNewEventAttributes{ NewExecutionRunId: newRunID, }}, }, @@ -649,15 +651,15 @@ func (s *workflowRunSuite) TestExecuteWorkflow_NoDup_ContinueAsNew() { workflowResult := time.Hour * 59 encodedResult, _ := encodeArg(getDefaultDataConverter(), workflowResult) - eventType2 := enums.EventTypeWorkflowExecutionCompleted + eventType2 := eventpb.EventTypeWorkflowExecutionCompleted getRequest2 := getGetWorkflowExecutionHistoryRequest(filterType) getRequest2.Execution.RunId = newRunID getResponse2 := &workflowservice.GetWorkflowExecutionHistoryResponse{ - History: &commonproto.History{ - Events: []*commonproto.HistoryEvent{ + History: &eventpb.History{ + Events: []*eventpb.HistoryEvent{ { EventType: eventType2, - Attributes: &commonproto.HistoryEvent_WorkflowExecutionCompletedEventAttributes{WorkflowExecutionCompletedEventAttributes: &commonproto.WorkflowExecutionCompletedEventAttributes{ + Attributes: &eventpb.HistoryEvent_WorkflowExecutionCompletedEventAttributes{WorkflowExecutionCompletedEventAttributes: &eventpb.WorkflowExecutionCompletedEventAttributes{ Result: encodedResult, }}, }, @@ -687,17 +689,17 @@ func (s *workflowRunSuite) TestExecuteWorkflow_NoDup_ContinueAsNew() { } func (s *workflowRunSuite) TestGetWorkflow() { - filterType := enums.HistoryEventFilterTypeCloseEvent - eventType := enums.EventTypeWorkflowExecutionCompleted + filterType := filterpb.HistoryEventFilterTypeCloseEvent + eventType := eventpb.EventTypeWorkflowExecutionCompleted workflowResult := time.Hour * 59 encodedResult, _ := encodeArg(getDefaultDataConverter(), workflowResult) getRequest := getGetWorkflowExecutionHistoryRequest(filterType) getResponse := &workflowservice.GetWorkflowExecutionHistoryResponse{ - History: &commonproto.History{ - Events: []*commonproto.HistoryEvent{ + History: &eventpb.History{ + Events: []*eventpb.HistoryEvent{ { EventType: eventType, - Attributes: &commonproto.HistoryEvent_WorkflowExecutionCompletedEventAttributes{WorkflowExecutionCompletedEventAttributes: &commonproto.WorkflowExecutionCompletedEventAttributes{ + Attributes: &eventpb.HistoryEvent_WorkflowExecutionCompletedEventAttributes{WorkflowExecutionCompletedEventAttributes: &eventpb.WorkflowExecutionCompletedEventAttributes{ Result: encodedResult, }}, }, @@ -723,10 +725,10 @@ func (s *workflowRunSuite) TestGetWorkflow() { s.Equal(workflowResult, decodedResult) } -func getGetWorkflowExecutionHistoryRequest(filterType enums.HistoryEventFilterType) *workflowservice.GetWorkflowExecutionHistoryRequest { +func getGetWorkflowExecutionHistoryRequest(filterType filterpb.HistoryEventFilterType) *workflowservice.GetWorkflowExecutionHistoryRequest { request := &workflowservice.GetWorkflowExecutionHistoryRequest{ Namespace: DefaultNamespace, - Execution: &commonproto.WorkflowExecution{ + Execution: &executionpb.WorkflowExecution{ WorkflowId: workflowID, RunId: runID, }, diff --git a/internal/internal_workflow_testsuite.go b/internal/internal_workflow_testsuite.go index 56b474166..f493e2324 100644 --- a/internal/internal_workflow_testsuite.go +++ b/internal/internal_workflow_testsuite.go @@ -35,8 +35,10 @@ import ( "github.com/robfig/cron" "github.com/stretchr/testify/mock" "github.com/uber-go/tally" - commonproto "go.temporal.io/temporal-proto/common" - "go.temporal.io/temporal-proto/enums" + + commonpb "go.temporal.io/temporal-proto/common" + eventpb "go.temporal.io/temporal-proto/event" + executionpb "go.temporal.io/temporal-proto/execution" "go.temporal.io/temporal-proto/serviceerror" "go.temporal.io/temporal-proto/workflowservice" "go.temporal.io/temporal-proto/workflowservicemock" @@ -132,7 +134,7 @@ type ( callbackChannel chan testCallbackHandle testTimeout time.Duration - header *commonproto.Header + header *commonpb.Header counterID int activities map[string]*testActivityHandle @@ -528,7 +530,7 @@ func (env *testWorkflowEnvironmentImpl) executeActivity( if err != nil { if err == context.DeadlineExceeded { env.logger.Debug(fmt.Sprintf("Activity %v timed out", task.ActivityType.Name)) - return nil, NewTimeoutError(enums.TimeoutTypeStartToClose, context.DeadlineExceeded.Error()) + return nil, NewTimeoutError(eventpb.TimeoutTypeStartToClose, context.DeadlineExceeded.Error()) } topLine := fmt.Sprintf("activity for %s [panic]:", defaultTestTaskList) st := getStackTraceRaw(topLine, 7, 0) @@ -1044,7 +1046,7 @@ func (env *testWorkflowEnvironmentImpl) executeActivityWithRetryForTest( return } -func fromProtoRetryPolicy(p *commonproto.RetryPolicy) *RetryPolicy { +func fromProtoRetryPolicy(p *commonpb.RetryPolicy) *RetryPolicy { return &RetryPolicy{ InitialInterval: time.Second * time.Duration(p.GetInitialIntervalInSeconds()), BackoffCoefficient: p.GetBackoffCoefficient(), @@ -1055,7 +1057,7 @@ func fromProtoRetryPolicy(p *commonproto.RetryPolicy) *RetryPolicy { } } -func getRetryBackoffFromProtoRetryPolicy(prp *commonproto.RetryPolicy, attempt int32, errReason string, now, expireTime time.Time) time.Duration { +func getRetryBackoffFromProtoRetryPolicy(prp *commonpb.RetryPolicy, attempt int32, errReason string, now, expireTime time.Time) time.Duration { if prp == nil { return noRetryBackoff } @@ -1152,7 +1154,7 @@ func (env *testWorkflowEnvironmentImpl) handleActivityResult(activityID string, activityHandle.callback(blob, nil) default: if result == context.DeadlineExceeded { - err = NewTimeoutError(enums.TimeoutTypeStartToClose, context.DeadlineExceeded.Error()) + err = NewTimeoutError(eventpb.TimeoutTypeStartToClose, context.DeadlineExceeded.Error()) activityHandle.callback(nil, err) } else { panic(fmt.Sprintf("unsupported respond type %T", result)) @@ -1557,20 +1559,20 @@ func (env *testWorkflowEnvironmentImpl) newTestActivityTaskHandler(taskList stri func newTestActivityTask(workflowID, runID, activityID, workflowTypeName, namespace string, params executeActivityParams) *workflowservice.PollForActivityTaskResponse { task := &workflowservice.PollForActivityTaskResponse{ - WorkflowExecution: &commonproto.WorkflowExecution{ + WorkflowExecution: &executionpb.WorkflowExecution{ WorkflowId: workflowID, RunId: runID, }, ActivityId: activityID, TaskToken: []byte(activityID), // use activityID as TaskToken so we can map TaskToken in heartbeat calls. - ActivityType: &commonproto.ActivityType{Name: params.ActivityType.Name}, + ActivityType: &commonpb.ActivityType{Name: params.ActivityType.Name}, Input: params.Input, ScheduledTimestamp: time.Now().UnixNano(), ScheduleToCloseTimeoutSeconds: params.ScheduleToCloseTimeoutSeconds, StartedTimestamp: time.Now().UnixNano(), StartToCloseTimeoutSeconds: params.StartToCloseTimeoutSeconds, HeartbeatTimeoutSeconds: params.HeartbeatTimeoutSeconds, - WorkflowType: &commonproto.WorkflowType{ + WorkflowType: &commonpb.WorkflowType{ Name: workflowTypeName, }, WorkflowNamespace: namespace, diff --git a/internal/internal_workflow_testsuite_test.go b/internal/internal_workflow_testsuite_test.go index 174fe8ba2..bac5b9aca 100644 --- a/internal/internal_workflow_testsuite_test.go +++ b/internal/internal_workflow_testsuite_test.go @@ -32,12 +32,12 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/suite" + commonpb "go.temporal.io/temporal-proto/common" + eventpb "go.temporal.io/temporal-proto/event" + executionpb "go.temporal.io/temporal-proto/execution" "go.temporal.io/temporal-proto/serviceerror" "go.uber.org/atomic" "go.uber.org/zap" - - commonproto "go.temporal.io/temporal-proto/common" - "go.temporal.io/temporal-proto/enums" ) type WorkflowTestSuiteUnitTest struct { @@ -58,7 +58,7 @@ func (s *WorkflowTestSuiteUnitTest) SetupSuite() { s.localActivityOptions = LocalActivityOptions{ ScheduleToCloseTimeout: time.Second * 3, } - s.header = &commonproto.Header{ + s.header = &commonpb.Header{ Fields: map[string][]byte{"test": []byte("test-data")}, } s.contextPropagators = []ContextPropagator{NewStringMapPropagator([]string{"test"})} @@ -385,7 +385,7 @@ func (s *WorkflowTestSuiteUnitTest) Test_ActivityWithHeaderContext() { return "", errors.New("value not found from ctx") } - s.SetHeader(&commonproto.Header{ + s.SetHeader(&commonpb.Header{ Fields: map[string][]byte{ testHeader: []byte("test-data"), }, @@ -1389,34 +1389,34 @@ func (s *WorkflowTestSuiteUnitTest) Test_MockUpsertSearchAttributes() { func (s *WorkflowTestSuiteUnitTest) Test_ActivityWithProtoTypes() { var actualValues []string - retVal := &commonproto.WorkflowExecution{WorkflowId: "retwID2", RunId: "retrID2"} + retVal := &executionpb.WorkflowExecution{WorkflowId: "retwID2", RunId: "retrID2"} // Passing one argument - activitySingleFn := func(ctx context.Context, wf *commonproto.WorkflowExecution) (*commonproto.WorkflowExecution, error) { + activitySingleFn := func(ctx context.Context, wf *executionpb.WorkflowExecution) (*executionpb.WorkflowExecution, error) { actualValues = append(actualValues, wf.GetWorkflowId()) actualValues = append(actualValues, wf.GetRunId()) return retVal, nil } - input := &commonproto.WorkflowExecution{WorkflowId: "wID1", RunId: "rID1"} + input := &executionpb.WorkflowExecution{WorkflowId: "wID1", RunId: "rID1"} env := s.NewTestActivityEnvironment() env.RegisterActivity(activitySingleFn) blob, err := env.ExecuteActivity(activitySingleFn, input) s.NoError(err) - var ret *commonproto.WorkflowExecution + var ret *executionpb.WorkflowExecution _ = blob.Get(&ret) s.Equal(retVal, ret) // Passing more than one argument - activityDoubleArgFn := func(ctx context.Context, wf *commonproto.WorkflowExecution, t *commonproto.WorkflowType) (*commonproto.WorkflowExecution, error) { + activityDoubleArgFn := func(ctx context.Context, wf *executionpb.WorkflowExecution, t *commonpb.WorkflowType) (*executionpb.WorkflowExecution, error) { actualValues = append(actualValues, wf.GetWorkflowId()) actualValues = append(actualValues, wf.GetRunId()) actualValues = append(actualValues, t.GetName()) return retVal, nil } - input = &commonproto.WorkflowExecution{WorkflowId: "wID2", RunId: "rID3"} - wt := &commonproto.WorkflowType{Name: "wType"} + input = &executionpb.WorkflowExecution{WorkflowId: "wID2", RunId: "rID3"} + wt := &commonpb.WorkflowType{Name: "wType"} env = s.NewTestActivityEnvironment() env.RegisterActivity(activityDoubleArgFn) blob, err = env.ExecuteActivity(activityDoubleArgFn, input, wt) @@ -1570,7 +1570,7 @@ func (s *WorkflowTestSuiteUnitTest) Test_WorkflowHeaderContext() { } s.SetContextPropagators([]ContextPropagator{NewStringMapPropagator([]string{testHeader})}) - s.SetHeader(&commonproto.Header{ + s.SetHeader(&commonpb.Header{ Fields: map[string][]byte{ testHeader: []byte("test-data"), }, @@ -2822,7 +2822,7 @@ func (s *WorkflowTestSuiteUnitTest) Test_ActivityTimeoutWithDetails() { count := 0 timeoutFn := func() error { count++ - return NewTimeoutError(enums.TimeoutTypeStartToClose, testErrorDetails1) + return NewTimeoutError(eventpb.TimeoutTypeStartToClose, testErrorDetails1) } timeoutWf := func(ctx Context) error { @@ -2850,7 +2850,7 @@ func (s *WorkflowTestSuiteUnitTest) Test_ActivityTimeoutWithDetails() { s.Error(err) timeoutErr, ok := err.(*TimeoutError) s.True(ok) - s.Equal(enums.TimeoutTypeStartToClose, timeoutErr.TimeoutType()) + s.Equal(eventpb.TimeoutTypeStartToClose, timeoutErr.TimeoutType()) s.True(timeoutErr.HasDetails()) var details string err = timeoutErr.Details(&details) @@ -2865,7 +2865,7 @@ func (s *WorkflowTestSuiteUnitTest) Test_ActivityTimeoutWithDetails() { s.Error(err) timeoutErr, ok = err.(*TimeoutError) s.True(ok) - s.Equal(enums.TimeoutTypeStartToClose, timeoutErr.TimeoutType()) + s.Equal(eventpb.TimeoutTypeStartToClose, timeoutErr.TimeoutType()) s.True(timeoutErr.HasDetails()) err = timeoutErr.Details(&details) s.NoError(err) @@ -2896,7 +2896,7 @@ func (s *WorkflowTestSuiteUnitTest) Test_ActivityDeadlineExceeded() { s.Error(err) timeoutErr, ok := err.(*TimeoutError) s.True(ok) - s.Equal(enums.TimeoutTypeStartToClose, timeoutErr.TimeoutType()) + s.Equal(eventpb.TimeoutTypeStartToClose, timeoutErr.TimeoutType()) s.True(timeoutErr.HasDetails()) var details string err = timeoutErr.Details(&details) diff --git a/internal/tracer_test.go b/internal/tracer_test.go index ca9e5face..0765b9717 100644 --- a/internal/tracer_test.go +++ b/internal/tracer_test.go @@ -28,9 +28,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" jaeger_config "github.com/uber/jaeger-client-go/config" + commonpb "go.temporal.io/temporal-proto/common" "go.uber.org/zap" - - commonproto "go.temporal.io/temporal-proto/common" ) func TestTracingContextPropagator(t *testing.T) { @@ -43,7 +42,7 @@ func TestTracingContextPropagator(t *testing.T) { span := tracer.StartSpan("test-operation") ctx := context.Background() ctx = opentracing.ContextWithSpan(ctx, span) - header := &commonproto.Header{ + header := &commonpb.Header{ Fields: map[string][]byte{}, } @@ -62,7 +61,7 @@ func TestTracingContextPropagatorNoSpan(t *testing.T) { t.Parallel() ctxProp := NewTracingContextPropagator(zap.NewNop(), opentracing.NoopTracer{}) - header := &commonproto.Header{ + header := &commonpb.Header{ Fields: map[string][]byte{}, } err := ctxProp.Inject(context.Background(), NewHeaderWriter(header)) @@ -83,7 +82,7 @@ func TestTracingContextPropagatorWorkflowContext(t *testing.T) { span := tracer.StartSpan("test-operation") assert.NotNil(t, span.Context()) ctx := contextWithSpan(Background(), span.Context()) - header := &commonproto.Header{ + header := &commonpb.Header{ Fields: map[string][]byte{}, } @@ -107,7 +106,7 @@ func TestTracingContextPropagatorWorkflowContextNoSpan(t *testing.T) { t.Parallel() ctxProp := NewTracingContextPropagator(zap.NewNop(), opentracing.NoopTracer{}) - header := &commonproto.Header{ + header := &commonpb.Header{ Fields: map[string][]byte{}, } err := ctxProp.InjectFromWorkflow(Background(), NewHeaderWriter(header)) diff --git a/internal/workflow.go b/internal/workflow.go index 29c20a548..40a1631b2 100644 --- a/internal/workflow.go +++ b/internal/workflow.go @@ -28,10 +28,11 @@ import ( "time" "github.com/uber-go/tally" - commonproto "go.temporal.io/temporal-proto/common" + commonpb "go.temporal.io/temporal-proto/common" + "go.uber.org/zap" + "go.temporal.io/temporal/internal/common" "go.temporal.io/temporal/internal/common/backoff" - "go.uber.org/zap" ) var ( @@ -691,8 +692,8 @@ func (wc *workflowEnvironmentInterceptor) ExecuteChildWorkflow(ctx Context, chil return result } -func getWorkflowHeader(ctx Context, ctxProps []ContextPropagator) *commonproto.Header { - header := &commonproto.Header{ +func getWorkflowHeader(ctx Context, ctxProps []ContextPropagator) *commonpb.Header { + header := &commonpb.Header{ Fields: make(map[string][]byte), } writer := NewHeaderWriter(header) @@ -716,8 +717,8 @@ type WorkflowInfo struct { ContinuedExecutionRunID string ParentWorkflowNamespace string ParentWorkflowExecution *WorkflowExecution - Memo *commonproto.Memo // Value can be decoded using data converter (DefaultDataConverter, or custom one if set). - SearchAttributes *commonproto.SearchAttributes // Value can be decoded using DefaultDataConverter. + Memo *commonpb.Memo // Value can be decoded using data converter (DefaultDataConverter, or custom one if set). + SearchAttributes *commonpb.SearchAttributes // Value can be decoded using DefaultDataConverter. BinaryChecksum string } @@ -1421,14 +1422,14 @@ func WithRetryPolicy(ctx Context, retryPolicy RetryPolicy) Context { return ctx1 } -func convertRetryPolicy(retryPolicy *RetryPolicy) *commonproto.RetryPolicy { +func convertRetryPolicy(retryPolicy *RetryPolicy) *commonpb.RetryPolicy { if retryPolicy == nil { return nil } if retryPolicy.BackoffCoefficient == 0 { retryPolicy.BackoffCoefficient = backoff.DefaultBackoffCoefficient } - return &commonproto.RetryPolicy{ + return &commonpb.RetryPolicy{ MaximumIntervalInSeconds: common.Int32Ceil(retryPolicy.MaximumInterval.Seconds()), InitialIntervalInSeconds: common.Int32Ceil(retryPolicy.InitialInterval.Seconds()), BackoffCoefficient: retryPolicy.BackoffCoefficient, diff --git a/internal/workflow_testsuite.go b/internal/workflow_testsuite.go index 086093f38..17efec246 100644 --- a/internal/workflow_testsuite.go +++ b/internal/workflow_testsuite.go @@ -31,8 +31,8 @@ import ( "github.com/uber-go/tally" "go.uber.org/zap" - commonproto "go.temporal.io/temporal-proto/common" - "go.temporal.io/temporal-proto/enums" + commonpb "go.temporal.io/temporal-proto/common" + eventpb "go.temporal.io/temporal-proto/event" ) type ( @@ -50,7 +50,7 @@ type ( logger *zap.Logger scope tally.Scope contextPropagators []ContextPropagator - header *commonproto.Header + header *commonpb.Header } // TestWorkflowEnvironment is the environment that you use to test workflow @@ -150,7 +150,7 @@ func (s *WorkflowTestSuite) SetContextPropagators(ctxProps []ContextPropagator) // SetHeader sets the headers for this WorkflowTestSuite. If you don't set header, test suite will not pass headers to // the workflow -func (s *WorkflowTestSuite) SetHeader(header *commonproto.Header) { +func (s *WorkflowTestSuite) SetHeader(header *commonpb.Header) { s.header = header } @@ -296,7 +296,7 @@ func (t *TestWorkflowEnvironment) OnActivity(activity interface{}, args ...inter // ErrMockStartChildWorkflowFailed is special error used to indicate the mocked child workflow should fail to start. // This error is also exposed as public as testsuite.ErrMockStartChildWorkflowFailed -var ErrMockStartChildWorkflowFailed = fmt.Errorf("start child workflow failed: %v", enums.ChildWorkflowExecutionFailedCauseWorkflowAlreadyRunning) +var ErrMockStartChildWorkflowFailed = fmt.Errorf("start child workflow failed: %v", eventpb.ChildWorkflowExecutionFailedCauseWorkflowAlreadyRunning) // OnWorkflow setup a mock call for workflow. Parameter workflow must be workflow function (func) or workflow name (string). // You must call Return() with appropriate parameters on the returned *MockCallWrapper instance. The supplied parameters to diff --git a/mocks/Client.go b/mocks/Client.go index 163939887..7ea9a36ab 100644 --- a/mocks/Client.go +++ b/mocks/Client.go @@ -27,8 +27,8 @@ import ( "context" "github.com/stretchr/testify/mock" - - "go.temporal.io/temporal-proto/enums" + filterpb "go.temporal.io/temporal-proto/filter" + tasklistpb "go.temporal.io/temporal-proto/tasklist" "go.temporal.io/temporal-proto/workflowservice" "go.temporal.io/temporal/client" @@ -108,11 +108,11 @@ func (_m *Client) CountWorkflow(ctx context.Context, request *workflowservice.Co } // DescribeTaskList provides a mock function with given fields: ctx, tasklist, tasklistType -func (_m *Client) DescribeTaskList(ctx context.Context, tasklist string, tasklistType enums.TaskListType) (*workflowservice.DescribeTaskListResponse, error) { +func (_m *Client) DescribeTaskList(ctx context.Context, tasklist string, tasklistType tasklistpb.TaskListType) (*workflowservice.DescribeTaskListResponse, error) { ret := _m.Called(ctx, tasklist, tasklistType) var r0 *workflowservice.DescribeTaskListResponse - if rf, ok := ret.Get(0).(func(context.Context, string, enums.TaskListType) *workflowservice.DescribeTaskListResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, tasklistpb.TaskListType) *workflowservice.DescribeTaskListResponse); ok { r0 = rf(ctx, tasklist, tasklistType) } else { if ret.Get(0) != nil { @@ -121,7 +121,7 @@ func (_m *Client) DescribeTaskList(ctx context.Context, tasklist string, tasklis } var r1 error - if rf, ok := ret.Get(1).(func(context.Context, string, enums.TaskListType) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, string, tasklistpb.TaskListType) error); ok { r1 = rf(ctx, tasklist, tasklistType) } else { r1 = ret.Error(1) @@ -219,11 +219,11 @@ func (_m *Client) GetWorkflow(ctx context.Context, workflowID string, runID stri } // GetWorkflowHistory provides a mock function with given fields: ctx, workflowID, runID, isLongPoll, filterType -func (_m *Client) GetWorkflowHistory(ctx context.Context, workflowID string, runID string, isLongPoll bool, filterType enums.HistoryEventFilterType) client.HistoryEventIterator { +func (_m *Client) GetWorkflowHistory(ctx context.Context, workflowID string, runID string, isLongPoll bool, filterType filterpb.HistoryEventFilterType) client.HistoryEventIterator { ret := _m.Called(ctx, workflowID, runID, isLongPoll, filterType) var r0 internal.HistoryEventIterator - if rf, ok := ret.Get(0).(func(context.Context, string, string, bool, enums.HistoryEventFilterType) internal.HistoryEventIterator); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string, bool, filterpb.HistoryEventFilterType) internal.HistoryEventIterator); ok { r0 = rf(ctx, workflowID, runID, isLongPoll, filterType) } else { if ret.Get(0) != nil { diff --git a/mocks/HistoryEventIterator.go b/mocks/HistoryEventIterator.go index f9cd35d01..62b1c6445 100644 --- a/mocks/HistoryEventIterator.go +++ b/mocks/HistoryEventIterator.go @@ -23,7 +23,7 @@ package mocks import ( "github.com/stretchr/testify/mock" - commonproto "go.temporal.io/temporal-proto/common" + eventpb "go.temporal.io/temporal-proto/event" ) // HistoryEventIterator is an autogenerated mock type for the HistoryEventIterator type @@ -46,15 +46,15 @@ func (_m *HistoryEventIterator) HasNext() bool { } // Next provides a mock function with given fields: -func (_m *HistoryEventIterator) Next() (*commonproto.HistoryEvent, error) { +func (_m *HistoryEventIterator) Next() (*eventpb.HistoryEvent, error) { ret := _m.Called() - var r0 *commonproto.HistoryEvent - if rf, ok := ret.Get(0).(func() *commonproto.HistoryEvent); ok { + var r0 *eventpb.HistoryEvent + if rf, ok := ret.Get(0).(func() *eventpb.HistoryEvent); ok { r0 = rf() } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*commonproto.HistoryEvent) + r0 = ret.Get(0).(*eventpb.HistoryEvent) } } diff --git a/mocks/mock_test.go b/mocks/mock_test.go index a03816d96..f13e4da20 100644 --- a/mocks/mock_test.go +++ b/mocks/mock_test.go @@ -27,8 +27,8 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - commonproto "go.temporal.io/temporal-proto/common" - "go.temporal.io/temporal-proto/enums" + eventpb "go.temporal.io/temporal-proto/event" + filterpb "go.temporal.io/temporal-proto/filter" "go.temporal.io/temporal/client" "go.temporal.io/temporal/workflow" @@ -87,10 +87,10 @@ func Test_MockClient(t *testing.T) { mockHistoryIter := &HistoryEventIterator{} mockHistoryIter.On("HasNext").Return(true).Once() - mockHistoryIter.On("Next").Return(&commonproto.HistoryEvent{}, nil).Once() + mockHistoryIter.On("Next").Return(&eventpb.HistoryEvent{}, nil).Once() mockClient.On("GetWorkflowHistory", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything). Return(mockHistoryIter).Once() - historyIter := mockClient.GetWorkflowHistory(context.Background(), testWorkflowID, testRunID, true, enums.HistoryEventFilterTypeCloseEvent) + historyIter := mockClient.GetWorkflowHistory(context.Background(), testWorkflowID, testRunID, true, filterpb.HistoryEventFilterTypeCloseEvent) mockClient.AssertExpectations(t) require.NotNil(t, historyIter) require.Equal(t, true, historyIter.HasNext()) diff --git a/test/integration_test.go b/test/integration_test.go index fef21d198..dd5308439 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -32,7 +32,10 @@ import ( "github.com/pborman/uuid" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "go.temporal.io/temporal-proto/enums" + eventpb "go.temporal.io/temporal-proto/event" + executionpb "go.temporal.io/temporal-proto/execution" + filterpb "go.temporal.io/temporal-proto/filter" + querypb "go.temporal.io/temporal-proto/query" "go.temporal.io/temporal-proto/serviceerror" "go.temporal.io/temporal-proto/workflowservice" "go.uber.org/goleak" @@ -188,7 +191,7 @@ func (ts *IntegrationTestSuite) TestActivityRetryOnStartToCloseTimeout() { "test-activity-retry-on-start2close-timeout", ts.workflows.ActivityRetryOnTimeout, &expected, - enums.TimeoutTypeStartToClose) + eventpb.TimeoutTypeStartToClose) ts.NoError(err) ts.EqualValues(expected, ts.activities.invoked()) @@ -272,7 +275,7 @@ func (ts *IntegrationTestSuite) TestConsistentQuery() { WorkflowID: "test-consistent-query", RunID: run.GetRunID(), QueryType: "consistent_query", - QueryConsistencyLevel: enums.QueryConsistencyLevelStrong, + QueryConsistencyLevel: querypb.QueryConsistencyLevelStrong, }) ts.Nil(err) ts.NotNil(value) @@ -377,7 +380,7 @@ func (ts *IntegrationTestSuite) TestChildWFWithParentClosePolicyTerminate() { ts.NoError(err) info := resp.WorkflowExecutionInfo if info.GetCloseTime().GetValue() > 0 { - ts.Equal(enums.WorkflowExecutionStatusTerminated, info.GetStatus(), info) + ts.Equal(executionpb.WorkflowExecutionStatusTerminated, info.GetStatus(), info) break } time.Sleep(time.Millisecond * 500) @@ -394,7 +397,7 @@ func (ts *IntegrationTestSuite) TestChildWFWithParentClosePolicyAbandon() { ts.NoError(err) info := resp.WorkflowExecutionInfo if info.GetCloseTime().GetValue() > 0 { - ts.Equal(enums.WorkflowExecutionStatusCompleted, info.GetStatus(), info) + ts.Equal(executionpb.WorkflowExecutionStatusCompleted, info.GetStatus(), info) break } time.Sleep(time.Millisecond * 500) @@ -490,7 +493,7 @@ func (ts *IntegrationTestSuite) executeWorkflowWithOption( } err = run.Get(ctx, retValPtr) if ts.config.Debug { - iter := ts.client.GetWorkflowHistory(ctx, options.ID, run.GetRunID(), false, enums.HistoryEventFilterTypeAllEvent) + iter := ts.client.GetWorkflowHistory(ctx, options.ID, run.GetRunID(), false, filterpb.HistoryEventFilterTypeAllEvent) for iter.HasNext() { event, err1 := iter.Next() if err1 != nil { diff --git a/test/workflow_test.go b/test/workflow_test.go index 2f00cce41..01645aec0 100644 --- a/test/workflow_test.go +++ b/test/workflow_test.go @@ -26,7 +26,7 @@ import ( "math/rand" "time" - "go.temporal.io/temporal-proto/enums" + eventpb "go.temporal.io/temporal-proto/event" "go.temporal.io/temporal" "go.temporal.io/temporal/client" @@ -97,12 +97,12 @@ func (w *Workflows) ActivityRetryOptionsChange(ctx workflow.Context) ([]string, return []string{"fail", "fail"}, nil } -func (w *Workflows) ActivityRetryOnTimeout(ctx workflow.Context, timeoutType enums.TimeoutType) ([]string, error) { +func (w *Workflows) ActivityRetryOnTimeout(ctx workflow.Context, timeoutType eventpb.TimeoutType) ([]string, error) { opts := w.defaultActivityOptionsWithRetry() switch timeoutType { - case enums.TimeoutTypeScheduleToClose: + case eventpb.TimeoutTypeScheduleToClose: opts.ScheduleToCloseTimeout = time.Second - case enums.TimeoutTypeStartToClose: + case eventpb.TimeoutTypeStartToClose: opts.StartToCloseTimeout = time.Second } @@ -153,7 +153,7 @@ func (w *Workflows) ActivityRetryOnHBTimeout(ctx workflow.Context) ([]string, er return nil, fmt.Errorf("activity failed with unexpected error: %v", err) } - if terr.TimeoutType() != enums.TimeoutTypeHeartbeat { + if terr.TimeoutType() != eventpb.TimeoutTypeHeartbeat { return nil, fmt.Errorf("activity failed due to unexpected timeout %v", terr.TimeoutType()) } diff --git a/worker/worker.go b/worker/worker.go index b30eef8f7..c7eef73c3 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -24,7 +24,7 @@ package worker import ( "context" - commonproto "go.temporal.io/temporal-proto/common" + eventpb "go.temporal.io/temporal-proto/event" "go.temporal.io/temporal-proto/workflowservice" "go.uber.org/zap" @@ -135,7 +135,7 @@ type ( // ReplayWorkflowHistory executes a single decision task for the given json history file. // Use for testing the backwards compatibility of code changes and troubleshooting workflows in a debugger. // The logger is an optional parameter. Defaults to the noop logger. - ReplayWorkflowHistory(logger *zap.Logger, history *commonproto.History) error + ReplayWorkflowHistory(logger *zap.Logger, history *eventpb.History) error // ReplayWorkflowHistoryFromJSONFile executes a single decision task for the json history file downloaded from the cli. // To download the history file: temporal workflow showid -of diff --git a/workflow/error.go b/workflow/error.go index 4d27dc0ef..52fb884de 100644 --- a/workflow/error.go +++ b/workflow/error.go @@ -21,7 +21,7 @@ package workflow import ( - "go.temporal.io/temporal-proto/enums" + eventpb "go.temporal.io/temporal-proto/event" "go.temporal.io/temporal/internal" ) @@ -126,7 +126,7 @@ func NewContinueAsNewError(ctx Context, wfn interface{}, args ...interface{}) *C // Use NewHeartbeatTimeoutError to create heartbeat TimeoutError // WARNING: This function is public only to support unit testing of workflows. // It shouldn't be used by application level code. -func NewTimeoutError(timeoutType enums.TimeoutType, details ...interface{}) *TimeoutError { +func NewTimeoutError(timeoutType eventpb.TimeoutType, details ...interface{}) *TimeoutError { return internal.NewTimeoutError(timeoutType, details...) }