Skip to content

Commit

Permalink
Rearrange proto files (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexshtin committed Apr 4, 2020
1 parent b7eeb0e commit 68e7f35
Show file tree
Hide file tree
Showing 43 changed files with 1,046 additions and 1,004 deletions.
7 changes: 4 additions & 3 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
36 changes: 19 additions & 17 deletions evictiontest/workflow_cache_eviction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
}
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.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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
24 changes: 13 additions & 11 deletions internal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
}
Expand Down
66 changes: 33 additions & 33 deletions internal/common/util/stringer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions internal/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions internal/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"fmt"
"strings"

"go.temporal.io/temporal-proto/enums"
eventpb "go.temporal.io/temporal-proto/event"
)

/*
Expand Down Expand Up @@ -97,7 +97,7 @@ type (

// TimeoutError returned when activity or child workflow timed out.
TimeoutError struct {
timeoutType enums.TimeoutType
timeoutType eventpb.TimeoutType
details Values
}

Expand Down Expand Up @@ -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}
Expand All @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
Loading

0 comments on commit 68e7f35

Please sign in to comment.