Skip to content

Commit

Permalink
Remove type prefix from enum values (#87)
Browse files Browse the repository at this point in the history
* Remove enum type prefix.

* Fix import path.

* Update go.temporal.io/temporal-proto.
  • Loading branch information
alexshtin authored Apr 4, 2020
1 parent 68e7f35 commit 561d426
Show file tree
Hide file tree
Showing 36 changed files with 419 additions and 421 deletions.
4 changes: 2 additions & 2 deletions evictiontest/workflow_cache_eviction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ func TestWorkersTestSuite(t *testing.T) {
func createTestEventWorkflowExecutionStarted(eventID int64, attr *eventpb.WorkflowExecutionStartedEventAttributes) *eventpb.HistoryEvent {
return &eventpb.HistoryEvent{
EventId: eventID,
EventType: eventpb.EventTypeWorkflowExecutionStarted,
EventType: eventpb.EventType_WorkflowExecutionStarted,
Attributes: &eventpb.HistoryEvent_WorkflowExecutionStartedEventAttributes{WorkflowExecutionStartedEventAttributes: attr}}
}

func createTestEventDecisionTaskScheduled(eventID int64, attr *eventpb.DecisionTaskScheduledEventAttributes) *eventpb.HistoryEvent {
return &eventpb.HistoryEvent{
EventId: eventID,
EventType: eventpb.EventTypeDecisionTaskScheduled,
EventType: eventpb.EventType_DecisionTaskScheduled,
Attributes: &eventpb.HistoryEvent_DecisionTaskScheduledEventAttributes{DecisionTaskScheduledEventAttributes: attr}}
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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.11
go.temporal.io/temporal-proto v0.20.14
go.uber.org/atomic v1.6.0
go.uber.org/goleak v1.0.0
go.uber.org/zap v1.14.1
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,8 @@ github.com/uber/jaeger-client-go v2.22.1+incompatible/go.mod h1:WVhlPFC8FDjOFMMW
github.com/uber/jaeger-lib v2.2.0+incompatible h1:MxZXOiR2JuoANZ3J6DE/U0kSFv/eJ/GfSYVCjK7dyaw=
github.com/uber/jaeger-lib v2.2.0+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U=
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.temporal.io/temporal-proto v0.20.14 h1:dpDmpCGy/eQbusg1b0b32/4HnFZXtrY1sZKxvQa2WiY=
go.temporal.io/temporal-proto v0.20.14/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=
Expand Down
12 changes: 6 additions & 6 deletions internal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,11 +649,11 @@ func newNamespaceServiceClient(workflowServiceClient workflowservice.WorkflowSer
func (p WorkflowIDReusePolicy) toProto() commonpb.WorkflowIdReusePolicy {
switch p {
case WorkflowIDReusePolicyAllowDuplicate:
return commonpb.WorkflowIdReusePolicyAllowDuplicate
return commonpb.WorkflowIdReusePolicy_AllowDuplicate
case WorkflowIDReusePolicyAllowDuplicateFailedOnly:
return commonpb.WorkflowIdReusePolicyAllowDuplicateFailedOnly
return commonpb.WorkflowIdReusePolicy_AllowDuplicateFailedOnly
case WorkflowIDReusePolicyRejectDuplicate:
return commonpb.WorkflowIdReusePolicyRejectDuplicate
return commonpb.WorkflowIdReusePolicy_RejectDuplicate
default:
panic(fmt.Sprintf("unknown workflow reuse policy %v", p))
}
Expand All @@ -662,11 +662,11 @@ func (p WorkflowIDReusePolicy) toProto() commonpb.WorkflowIdReusePolicy {
func (p ParentClosePolicy) toProto() commonpb.ParentClosePolicy {
switch p {
case ParentClosePolicyAbandon:
return commonpb.ParentClosePolicyAbandon
return commonpb.ParentClosePolicy_Abandon
case ParentClosePolicyRequestCancel:
return commonpb.ParentClosePolicyRequestCancel
return commonpb.ParentClosePolicy_RequestCancel
case ParentClosePolicyTerminate:
return commonpb.ParentClosePolicyTerminate
return commonpb.ParentClosePolicy_Terminate
default:
panic(fmt.Sprintf("unknown workflow parent close policy %v", p))
}
Expand Down
58 changes: 29 additions & 29 deletions internal/common/util/stringer.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,70 +81,70 @@ func valueToString(v reflect.Value) string {
func HistoryEventToString(e *eventpb.HistoryEvent) string {
var data interface{}
switch e.GetEventType() {
case eventpb.EventTypeWorkflowExecutionStarted:
case eventpb.EventType_WorkflowExecutionStarted:
data = e.GetWorkflowExecutionStartedEventAttributes()

case eventpb.EventTypeWorkflowExecutionCompleted:
case eventpb.EventType_WorkflowExecutionCompleted:
data = e.GetWorkflowExecutionCompletedEventAttributes()

case eventpb.EventTypeWorkflowExecutionFailed:
case eventpb.EventType_WorkflowExecutionFailed:
data = e.GetWorkflowExecutionFailedEventAttributes()

case eventpb.EventTypeWorkflowExecutionTimedOut:
case eventpb.EventType_WorkflowExecutionTimedOut:
data = e.GetWorkflowExecutionTimedOutEventAttributes()

case eventpb.EventTypeDecisionTaskScheduled:
case eventpb.EventType_DecisionTaskScheduled:
data = e.GetDecisionTaskScheduledEventAttributes()

case eventpb.EventTypeDecisionTaskStarted:
case eventpb.EventType_DecisionTaskStarted:
data = e.GetDecisionTaskStartedEventAttributes()

case eventpb.EventTypeDecisionTaskCompleted:
case eventpb.EventType_DecisionTaskCompleted:
data = e.GetDecisionTaskCompletedEventAttributes()

case eventpb.EventTypeDecisionTaskTimedOut:
case eventpb.EventType_DecisionTaskTimedOut:
data = e.GetDecisionTaskTimedOutEventAttributes()

case eventpb.EventTypeActivityTaskScheduled:
case eventpb.EventType_ActivityTaskScheduled:
data = e.GetActivityTaskScheduledEventAttributes()

case eventpb.EventTypeActivityTaskStarted:
case eventpb.EventType_ActivityTaskStarted:
data = e.GetActivityTaskStartedEventAttributes()

case eventpb.EventTypeActivityTaskCompleted:
case eventpb.EventType_ActivityTaskCompleted:
data = e.GetActivityTaskCompletedEventAttributes()

case eventpb.EventTypeActivityTaskFailed:
case eventpb.EventType_ActivityTaskFailed:
data = e.GetActivityTaskFailedEventAttributes()

case eventpb.EventTypeActivityTaskTimedOut:
case eventpb.EventType_ActivityTaskTimedOut:
data = e.GetActivityTaskTimedOutEventAttributes()

case eventpb.EventTypeActivityTaskCancelRequested:
case eventpb.EventType_ActivityTaskCancelRequested:
data = e.GetActivityTaskCancelRequestedEventAttributes()

case eventpb.EventTypeRequestCancelActivityTaskFailed:
case eventpb.EventType_RequestCancelActivityTaskFailed:
data = e.GetRequestCancelActivityTaskFailedEventAttributes()

case eventpb.EventTypeActivityTaskCanceled:
case eventpb.EventType_ActivityTaskCanceled:
data = e.GetActivityTaskCanceledEventAttributes()

case eventpb.EventTypeTimerStarted:
case eventpb.EventType_TimerStarted:
data = e.GetTimerStartedEventAttributes()

case eventpb.EventTypeTimerFired:
case eventpb.EventType_TimerFired:
data = e.GetTimerFiredEventAttributes()

case eventpb.EventTypeCancelTimerFailed:
case eventpb.EventType_CancelTimerFailed:
data = e.GetCancelTimerFailedEventAttributes()

case eventpb.EventTypeTimerCanceled:
case eventpb.EventType_TimerCanceled:
data = e.GetTimerCanceledEventAttributes()

case eventpb.EventTypeMarkerRecorded:
case eventpb.EventType_MarkerRecorded:
data = e.GetMarkerRecordedEventAttributes()

case eventpb.EventTypeWorkflowExecutionTerminated:
case eventpb.EventType_WorkflowExecutionTerminated:
data = e.GetWorkflowExecutionTerminatedEventAttributes()

default:
Expand All @@ -158,25 +158,25 @@ func HistoryEventToString(e *eventpb.HistoryEvent) string {
func DecisionToString(d *decisionpb.Decision) string {
var data interface{}
switch d.GetDecisionType() {
case decisionpb.DecisionTypeScheduleActivityTask:
case decisionpb.DecisionType_ScheduleActivityTask:
data = d.GetScheduleActivityTaskDecisionAttributes()

case decisionpb.DecisionTypeRequestCancelActivityTask:
case decisionpb.DecisionType_RequestCancelActivityTask:
data = d.GetRequestCancelActivityTaskDecisionAttributes()

case decisionpb.DecisionTypeStartTimer:
case decisionpb.DecisionType_StartTimer:
data = d.GetStartTimerDecisionAttributes()

case decisionpb.DecisionTypeCancelTimer:
case decisionpb.DecisionType_CancelTimer:
data = d.GetCancelTimerDecisionAttributes()

case decisionpb.DecisionTypeCompleteWorkflowExecution:
case decisionpb.DecisionType_CompleteWorkflowExecution:
data = d.GetCompleteWorkflowExecutionDecisionAttributes()

case decisionpb.DecisionTypeFailWorkflowExecution:
case decisionpb.DecisionType_FailWorkflowExecution:
data = d.GetFailWorkflowExecutionDecisionAttributes()

case decisionpb.DecisionTypeRecordMarker:
case decisionpb.DecisionType_RecordMarker:
data = d.GetRecordMarkerDecisionAttributes()

default:
Expand Down
2 changes: 1 addition & 1 deletion internal/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ var ErrCanceled = NewCanceledError()

// ErrDeadlineExceeded is the error returned by Context.Err when the context's
// deadline passes.
var ErrDeadlineExceeded = NewTimeoutError(eventpb.TimeoutTypeScheduleToClose)
var ErrDeadlineExceeded = NewTimeoutError(eventpb.TimeoutType_ScheduleToClose)

// A CancelFunc tells an operation to abandon its work.
// A CancelFunc does not wait for the work to stop.
Expand Down
2 changes: 1 addition & 1 deletion internal/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func NewTimeoutError(timeoutType eventpb.TimeoutType, details ...interface{}) *T

// NewHeartbeatTimeoutError creates TimeoutError instance
func NewHeartbeatTimeoutError(details ...interface{}) *TimeoutError {
return NewTimeoutError(eventpb.TimeoutTypeHeartbeat, details...)
return NewTimeoutError(eventpb.TimeoutType_Heartbeat, details...)
}

// NewCanceledError creates CanceledError instance
Expand Down
10 changes: 5 additions & 5 deletions internal/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func Test_ActivityNotRegistered(t *testing.T) {
}

func Test_TimeoutError(t *testing.T) {
timeoutErr := NewTimeoutError(eventpb.TimeoutTypeScheduleToStart)
timeoutErr := NewTimeoutError(eventpb.TimeoutType_ScheduleToStart)
require.False(t, timeoutErr.HasDetails())
var data string
require.Equal(t, ErrNoData, timeoutErr.Details(&data))
Expand All @@ -105,9 +105,9 @@ func Test_TimeoutError(t *testing.T) {
}

func Test_TimeoutError_WithDetails(t *testing.T) {
testTimeoutErrorDetails(t, eventpb.TimeoutTypeHeartbeat)
testTimeoutErrorDetails(t, eventpb.TimeoutTypeScheduleToClose)
testTimeoutErrorDetails(t, eventpb.TimeoutTypeStartToClose)
testTimeoutErrorDetails(t, eventpb.TimeoutType_Heartbeat)
testTimeoutErrorDetails(t, eventpb.TimeoutType_ScheduleToClose)
testTimeoutErrorDetails(t, eventpb.TimeoutType_StartToClose)
}

func testTimeoutErrorDetails(t *testing.T, timeoutType eventpb.TimeoutType) {
Expand Down Expand Up @@ -417,7 +417,7 @@ func Test_SignalExternalWorkflowExecutionFailedError(t *testing.T) {
weh := &workflowExecutionEventHandlerImpl{context, nil}
event := createTestEventSignalExternalWorkflowExecutionFailed(1, &eventpb.SignalExternalWorkflowExecutionFailedEventAttributes{
InitiatedEventId: initiatedEventID,
Cause: eventpb.SignalExternalWorkflowExecutionFailedCauseUnknownExternalWorkflowExecution,
Cause: eventpb.WorkflowExecutionFailedCause_UnknownExternalWorkflowExecution,
})
require.NoError(t, weh.handleSignalExternalWorkflowExecutionFailed(event))
_, ok := actualErr.(*UnknownExternalWorkflowExecutionError)
Expand Down
28 changes: 14 additions & 14 deletions internal/internal_decision_state_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,31 +262,31 @@ func (h *decisionsHelper) newNaiveDecisionStateMachine(decisionType decisionType
}

func (h *decisionsHelper) newMarkerDecisionStateMachine(id string, attributes *decisionpb.RecordMarkerDecisionAttributes) *markerDecisionStateMachine {
d := createNewDecision(decisionpb.DecisionTypeRecordMarker)
d := createNewDecision(decisionpb.DecisionType_RecordMarker)
d.Attributes = &decisionpb.Decision_RecordMarkerDecisionAttributes{RecordMarkerDecisionAttributes: attributes}
return &markerDecisionStateMachine{
naiveDecisionStateMachine: h.newNaiveDecisionStateMachine(decisionTypeMarker, id, d),
}
}

func (h *decisionsHelper) newCancelExternalWorkflowStateMachine(attributes *decisionpb.RequestCancelExternalWorkflowExecutionDecisionAttributes, cancellationID string) *cancelExternalWorkflowDecisionStateMachine {
d := createNewDecision(decisionpb.DecisionTypeRequestCancelExternalWorkflowExecution)
d := createNewDecision(decisionpb.DecisionType_RequestCancelExternalWorkflowExecution)
d.Attributes = &decisionpb.Decision_RequestCancelExternalWorkflowExecutionDecisionAttributes{RequestCancelExternalWorkflowExecutionDecisionAttributes: attributes}
return &cancelExternalWorkflowDecisionStateMachine{
naiveDecisionStateMachine: h.newNaiveDecisionStateMachine(decisionTypeCancellation, cancellationID, d),
}
}

func (h *decisionsHelper) newSignalExternalWorkflowStateMachine(attributes *decisionpb.SignalExternalWorkflowExecutionDecisionAttributes, signalID string) *signalExternalWorkflowDecisionStateMachine {
d := createNewDecision(decisionpb.DecisionTypeSignalExternalWorkflowExecution)
d := createNewDecision(decisionpb.DecisionType_SignalExternalWorkflowExecution)
d.Attributes = &decisionpb.Decision_SignalExternalWorkflowExecutionDecisionAttributes{SignalExternalWorkflowExecutionDecisionAttributes: attributes}
return &signalExternalWorkflowDecisionStateMachine{
naiveDecisionStateMachine: h.newNaiveDecisionStateMachine(decisionTypeSignal, signalID, d),
}
}

func (h *decisionsHelper) newUpsertSearchAttributesStateMachine(attributes *decisionpb.UpsertWorkflowSearchAttributesDecisionAttributes, upsertID string) *upsertSearchAttributesDecisionStateMachine {
d := createNewDecision(decisionpb.DecisionTypeUpsertWorkflowSearchAttributes)
d := createNewDecision(decisionpb.DecisionType_UpsertWorkflowSearchAttributes)
d.Attributes = &decisionpb.Decision_UpsertWorkflowSearchAttributesDecisionAttributes{UpsertWorkflowSearchAttributesDecisionAttributes: attributes}
return &upsertSearchAttributesDecisionStateMachine{
naiveDecisionStateMachine: h.newNaiveDecisionStateMachine(decisionTypeUpsertSearchAttributes, upsertID, d),
Expand Down Expand Up @@ -432,11 +432,11 @@ func (d *decisionStateMachineBase) String() string {
func (d *activityDecisionStateMachine) getDecision() *decisionpb.Decision {
switch d.state {
case decisionStateCreated:
decision := createNewDecision(decisionpb.DecisionTypeScheduleActivityTask)
decision := createNewDecision(decisionpb.DecisionType_ScheduleActivityTask)
decision.Attributes = &decisionpb.Decision_ScheduleActivityTaskDecisionAttributes{ScheduleActivityTaskDecisionAttributes: d.attributes}
return decision
case decisionStateCanceledAfterInitiated:
decision := createNewDecision(decisionpb.DecisionTypeRequestCancelActivityTask)
decision := createNewDecision(decisionpb.DecisionType_RequestCancelActivityTask)
decision.Attributes = &decisionpb.Decision_RequestCancelActivityTaskDecisionAttributes{RequestCancelActivityTaskDecisionAttributes: &decisionpb.RequestCancelActivityTaskDecisionAttributes{
ActivityId: d.attributes.ActivityId,
}}
Expand Down Expand Up @@ -494,11 +494,11 @@ func (d *timerDecisionStateMachine) handleCancelFailedEvent() {
func (d *timerDecisionStateMachine) getDecision() *decisionpb.Decision {
switch d.state {
case decisionStateCreated:
decision := createNewDecision(decisionpb.DecisionTypeStartTimer)
decision := createNewDecision(decisionpb.DecisionType_StartTimer)
decision.Attributes = &decisionpb.Decision_StartTimerDecisionAttributes{StartTimerDecisionAttributes: d.attributes}
return decision
case decisionStateCanceledAfterInitiated:
decision := createNewDecision(decisionpb.DecisionTypeCancelTimer)
decision := createNewDecision(decisionpb.DecisionType_CancelTimer)
decision.Attributes = &decisionpb.Decision_CancelTimerDecisionAttributes{CancelTimerDecisionAttributes: &decisionpb.CancelTimerDecisionAttributes{
TimerId: d.attributes.TimerId,
}}
Expand All @@ -511,11 +511,11 @@ func (d *timerDecisionStateMachine) getDecision() *decisionpb.Decision {
func (d *childWorkflowDecisionStateMachine) getDecision() *decisionpb.Decision {
switch d.state {
case decisionStateCreated:
decision := createNewDecision(decisionpb.DecisionTypeStartChildWorkflowExecution)
decision := createNewDecision(decisionpb.DecisionType_StartChildWorkflowExecution)
decision.Attributes = &decisionpb.Decision_StartChildWorkflowExecutionDecisionAttributes{StartChildWorkflowExecutionDecisionAttributes: d.attributes}
return decision
case decisionStateCanceledAfterStarted:
decision := createNewDecision(decisionpb.DecisionTypeRequestCancelExternalWorkflowExecution)
decision := createNewDecision(decisionpb.DecisionType_RequestCancelExternalWorkflowExecution)
decision.Attributes = &decisionpb.Decision_RequestCancelExternalWorkflowExecutionDecisionAttributes{RequestCancelExternalWorkflowExecutionDecisionAttributes: &decisionpb.RequestCancelExternalWorkflowExecutionDecisionAttributes{
Namespace: d.attributes.Namespace,
WorkflowId: d.attributes.WorkflowId,
Expand Down Expand Up @@ -757,13 +757,13 @@ func (h *decisionsHelper) handleRequestCancelActivityTaskFailed(activityID strin
func (h *decisionsHelper) getActivityID(event *eventpb.HistoryEvent) string {
var scheduledEventID int64 = -1
switch event.GetEventType() {
case eventpb.EventTypeActivityTaskCanceled:
case eventpb.EventType_ActivityTaskCanceled:
scheduledEventID = event.GetActivityTaskCanceledEventAttributes().GetScheduledEventId()
case eventpb.EventTypeActivityTaskCompleted:
case eventpb.EventType_ActivityTaskCompleted:
scheduledEventID = event.GetActivityTaskCompletedEventAttributes().GetScheduledEventId()
case eventpb.EventTypeActivityTaskFailed:
case eventpb.EventType_ActivityTaskFailed:
scheduledEventID = event.GetActivityTaskFailedEventAttributes().GetScheduledEventId()
case eventpb.EventTypeActivityTaskTimedOut:
case eventpb.EventType_ActivityTaskTimedOut:
scheduledEventID = event.GetActivityTaskTimedOutEventAttributes().GetScheduledEventId()
default:
panicIllegalState(fmt.Sprintf("unexpected event type %v", event.GetEventType()))
Expand Down
Loading

0 comments on commit 561d426

Please sign in to comment.