Skip to content

Commit

Permalink
Prefix enums with type and convert to upper case (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexshtin committed Jun 9, 2020
1 parent 8168f1b commit ac02e4f
Show file tree
Hide file tree
Showing 30 changed files with 347 additions and 347 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 @@ -95,14 +95,14 @@ func TestWorkersTestSuite(t *testing.T) {
func createTestEventWorkflowExecutionStarted(eventID int64, attr *eventpb.WorkflowExecutionStartedEventAttributes) *eventpb.HistoryEvent {
return &eventpb.HistoryEvent{
EventId: eventID,
EventType: eventpb.EventType_WorkflowExecutionStarted,
EventType: eventpb.EVENT_TYPE_WORKFLOW_EXECUTION_STARTED,
Attributes: &eventpb.HistoryEvent_WorkflowExecutionStartedEventAttributes{WorkflowExecutionStartedEventAttributes: attr}}
}

func createTestEventDecisionTaskScheduled(eventID int64, attr *eventpb.DecisionTaskScheduledEventAttributes) *eventpb.HistoryEvent {
return &eventpb.HistoryEvent{
EventId: eventID,
EventType: eventpb.EventType_DecisionTaskScheduled,
EventType: eventpb.EVENT_TYPE_DECISION_TASK_SCHEDULED,
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 @@ -21,7 +21,7 @@ require (
github.com/uber-go/tally v3.3.17+incompatible
github.com/uber/jaeger-client-go v2.23.1+incompatible
github.com/uber/jaeger-lib v2.2.0+incompatible // indirect
go.temporal.io/temporal-proto v0.23.5
go.temporal.io/temporal-proto v0.23.6
go.uber.org/atomic v1.6.0
go.uber.org/goleak v1.0.0
go.uber.org/zap v1.15.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ github.com/uber/jaeger-client-go v2.23.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.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.temporal.io/temporal-proto v0.23.5 h1:xJzulgFaaO5UvpkxeKRweZmOunLqqSS5QP103AG6GBQ=
go.temporal.io/temporal-proto v0.23.5/go.mod h1:U85R39c1zPKnKMJ/QXk6KC21Y3R9j7FUIhUwzxxMY+Y=
go.temporal.io/temporal-proto v0.23.6 h1:MHUDqJB2nptBSjZcDZMt/vv1rC8L0grTvwoRYHJwAG0=
go.temporal.io/temporal-proto v0.23.6/go.mod h1:lFt53MEhtjHIJtgg1U1Fdx3e3HoBOZcZKEbElzYz5Ro=
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 Expand Up @@ -184,8 +184,8 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto v0.0.0-20200605102947-12044bf5ea91 h1:ES+5k7Xz+sYByd2L7mvcanaIuY0Iz3L3O6OhN+cRdu8=
google.golang.org/genproto v0.0.0-20200605102947-12044bf5ea91/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
google.golang.org/genproto v0.0.0-20200608115520-7c474a2e3482 h1:i+Aiej6cta/Frzp13/swvwz5O00kYcSe0A/C5Wd7zX8=
google.golang.org/genproto v0.0.0-20200608115520-7c474a2e3482/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
Expand Down
12 changes: 6 additions & 6 deletions internal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,11 +643,11 @@ func newNamespaceServiceClient(workflowServiceClient workflowservice.WorkflowSer
func (p WorkflowIDReusePolicy) toProto() commonpb.WorkflowIdReusePolicy {
switch p {
case WorkflowIDReusePolicyAllowDuplicate:
return commonpb.WorkflowIdReusePolicy_AllowDuplicate
return commonpb.WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE
case WorkflowIDReusePolicyAllowDuplicateFailedOnly:
return commonpb.WorkflowIdReusePolicy_AllowDuplicateFailedOnly
return commonpb.WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY
case WorkflowIDReusePolicyRejectDuplicate:
return commonpb.WorkflowIdReusePolicy_RejectDuplicate
return commonpb.WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE
default:
panic(fmt.Sprintf("unknown workflow reuse policy %v", p))
}
Expand All @@ -656,11 +656,11 @@ func (p WorkflowIDReusePolicy) toProto() commonpb.WorkflowIdReusePolicy {
func (p ParentClosePolicy) toProto() commonpb.ParentClosePolicy {
switch p {
case ParentClosePolicyAbandon:
return commonpb.ParentClosePolicy_Abandon
return commonpb.PARENT_CLOSE_POLICY_ABANDON
case ParentClosePolicyRequestCancel:
return commonpb.ParentClosePolicy_RequestCancel
return commonpb.PARENT_CLOSE_POLICY_REQUEST_CANCEL
case ParentClosePolicyTerminate:
return commonpb.ParentClosePolicy_Terminate
return commonpb.PARENT_CLOSE_POLICY_TERMINATE
default:
panic(fmt.Sprintf("unknown workflow parent close policy %v", p))
}
Expand Down
14 changes: 7 additions & 7 deletions internal/common/serializer/serializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ func serializeProto(p proto.Marshaler, encodingType commonpb.EncodingType) (*com
var err error

switch encodingType {
case commonpb.EncodingType_Proto3:
case commonpb.ENCODING_TYPE_PROTO3:
data, err = p.Marshal()
case commonpb.EncodingType_JSON:
encodingType = commonpb.EncodingType_JSON
case commonpb.ENCODING_TYPE_JSON:
encodingType = commonpb.ENCODING_TYPE_JSON
pb, ok := p.(proto.Message)
if !ok {
return nil, NewSerializationError("could not cast protomarshal interface to proto.message")
Expand Down Expand Up @@ -123,9 +123,9 @@ func DeserializeBatchEvents(data *commonpb.DataBlob) ([]*eventpb.HistoryEvent, e
events := &eventpb.History{}
var err error
switch data.EncodingType {
case commonpb.EncodingType_JSON:
case commonpb.ENCODING_TYPE_JSON:
err = NewJSONPBEncoder().Decode(data.Data, events)
case commonpb.EncodingType_Proto3:
case commonpb.ENCODING_TYPE_PROTO3:
err = proto.Unmarshal(data.Data, events)
default:
return nil, NewDeserializationError("DeserializeBatchEvents invalid encoding")
Expand All @@ -149,7 +149,7 @@ func serialize(input interface{}, encodingType commonpb.EncodingType) (*commonpb
var err error

switch encodingType {
case commonpb.EncodingType_JSON: // For backward-compatibility
case commonpb.ENCODING_TYPE_JSON: // For backward-compatibility
data, err = json.Marshal(input)
default:
return nil, NewUnknownEncodingTypeError(encodingType)
Expand Down Expand Up @@ -222,7 +222,7 @@ func DeserializeBlobDataToHistoryEvents(
historyEvents = append(historyEvents, events...)
}

if filterType == filterpb.HistoryEventFilterType_CloseEvent {
if filterType == filterpb.HISTORY_EVENT_FILTER_TYPE_CLOSE_EVENT {
historyEvents = []*eventpb.HistoryEvent{historyEvents[len(historyEvents)-1]}
}
return &eventpb.History{Events: historyEvents}, nil
Expand Down
56 changes: 28 additions & 28 deletions internal/common/util/stringer.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,67 +85,67 @@ func valueToString(v reflect.Value) string {
func HistoryEventToString(e *eventpb.HistoryEvent) string {
var data interface{}
switch e.GetEventType() {
case eventpb.EventType_WorkflowExecutionStarted:
case eventpb.EVENT_TYPE_WORKFLOW_EXECUTION_STARTED:
data = e.GetWorkflowExecutionStartedEventAttributes()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

case decisionpb.DecisionType_RecordMarker:
case decisionpb.DECISION_TYPE_RECORD_MARKER:
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 @@ -179,7 +179,7 @@ var ErrCanceled = NewCanceledError()

// ErrDeadlineExceeded is the error returned by Context.Err when the context's
// deadline passes.
var ErrDeadlineExceeded = NewTimeoutError(commonpb.TimeoutType_ScheduleToClose, nil)
var ErrDeadlineExceeded = NewTimeoutError(commonpb.TIMEOUT_TYPE_SCHEDULE_TO_CLOSE, nil)

// A CancelFunc tells an operation to abandon its work.
// A CancelFunc does not wait for the work to stop.
Expand Down
6 changes: 3 additions & 3 deletions internal/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func NewTimeoutError(timeoutType commonpb.TimeoutType, cause error, lastHeatbeat

// NewHeartbeatTimeoutError creates TimeoutError instance.
func NewHeartbeatTimeoutError(details ...interface{}) *TimeoutError {
return NewTimeoutError(commonpb.TimeoutType_Heartbeat, nil, details...)
return NewTimeoutError(commonpb.TIMEOUT_TYPE_HEARTBEAT, nil, details...)
}

// NewCanceledError creates CanceledError instance.
Expand Down Expand Up @@ -616,8 +616,8 @@ func IsRetryable(err error, nonRetryableTypes []string) bool {

var timeoutErr *TimeoutError
if errors.As(err, &timeoutErr) {
if timeoutErr.timeoutType != commonpb.TimeoutType_StartToClose &&
timeoutErr.timeoutType != commonpb.TimeoutType_Heartbeat {
if timeoutErr.timeoutType != commonpb.TIMEOUT_TYPE_START_TO_CLOSE &&
timeoutErr.timeoutType != commonpb.TIMEOUT_TYPE_HEARTBEAT {
return false
}
}
Expand Down
Loading

0 comments on commit ac02e4f

Please sign in to comment.