Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch remaining task/matching types to internal #3767

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion common/persistence/dataInterfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/uber/cadence/common"
"github.com/uber/cadence/common/checksum"
"github.com/uber/cadence/common/codec"
"github.com/uber/cadence/common/types"
)

// Domain status
Expand Down Expand Up @@ -1130,7 +1131,7 @@ type (

// CreateTaskInfo describes a task to be created in CreateTasksRequest
CreateTaskInfo struct {
Execution workflow.WorkflowExecution
Execution types.WorkflowExecution
Data *TaskInfo
TaskID int64
}
Expand Down
32 changes: 16 additions & 16 deletions common/persistence/persistence-tests/matchingPersistenceTest.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"

gen "github.com/uber/cadence/.gen/go/shared"
"github.com/uber/cadence/common"
p "github.com/uber/cadence/common/persistence"
"github.com/uber/cadence/common/types"
)

type (
Expand Down Expand Up @@ -74,8 +74,8 @@ func (s *MatchingPersistenceSuite) TestCreateTask() {
defer cancel()

domainID := "11adbd1b-f164-4ea7-b2f3-2e857a5048f1"
workflowExecution := gen.WorkflowExecution{WorkflowId: common.StringPtr("create-task-test"),
RunId: common.StringPtr("c949447a-691a-4132-8b2a-a5b38106793c")}
workflowExecution := types.WorkflowExecution{WorkflowID: common.StringPtr("create-task-test"),
RunID: common.StringPtr("c949447a-691a-4132-8b2a-a5b38106793c")}
task0, err0 := s.CreateDecisionTask(ctx, domainID, workflowExecution, "a5b38106793c", 5)
s.NoError(err0)
s.NotNil(task0, "Expected non empty task identifier.")
Expand Down Expand Up @@ -105,8 +105,8 @@ func (s *MatchingPersistenceSuite) TestCreateTask() {
s.NoError(err)
s.Equal(1, len(resp.Tasks))
s.Equal(domainID, resp.Tasks[0].DomainID)
s.Equal(*workflowExecution.WorkflowId, resp.Tasks[0].WorkflowID)
s.Equal(*workflowExecution.RunId, resp.Tasks[0].RunID)
s.Equal(*workflowExecution.WorkflowID, resp.Tasks[0].WorkflowID)
s.Equal(*workflowExecution.RunID, resp.Tasks[0].RunID)
s.Equal(sid, resp.Tasks[0].ScheduleID)
s.True(resp.Tasks[0].CreatedTime.UnixNano() > 0)
if s.TaskMgr.GetName() != "cassandra" {
Expand All @@ -123,8 +123,8 @@ func (s *MatchingPersistenceSuite) TestGetDecisionTasks() {
defer cancel()

domainID := "aeac8287-527b-4b35-80a9-667cb47e7c6d"
workflowExecution := gen.WorkflowExecution{WorkflowId: common.StringPtr("get-decision-task-test"),
RunId: common.StringPtr("db20f7e2-1a1e-40d9-9278-d8b886738e05")}
workflowExecution := types.WorkflowExecution{WorkflowID: common.StringPtr("get-decision-task-test"),
RunID: common.StringPtr("db20f7e2-1a1e-40d9-9278-d8b886738e05")}
taskList := "d8b886738e05"
task0, err0 := s.CreateDecisionTask(ctx, domainID, workflowExecution, taskList, 5)
s.NoError(err0)
Expand All @@ -147,8 +147,8 @@ func (s *MatchingPersistenceSuite) TestGetTasksWithNoMaxReadLevel() {
return
}
domainID := "f1116985-d1f1-40e0-aba9-83344db915bc"
workflowExecution := gen.WorkflowExecution{WorkflowId: common.StringPtr("complete-decision-task-test"),
RunId: common.StringPtr("2aa0a74e-16ee-4f27-983d-48b07ec1915d")}
workflowExecution := types.WorkflowExecution{WorkflowID: common.StringPtr("complete-decision-task-test"),
RunID: common.StringPtr("2aa0a74e-16ee-4f27-983d-48b07ec1915d")}
taskList := "48b07ec1915d"
_, err0 := s.CreateActivityTasks(ctx, domainID, workflowExecution, map[int64]string{
10: taskList,
Expand Down Expand Up @@ -196,8 +196,8 @@ func (s *MatchingPersistenceSuite) TestCompleteDecisionTask() {
defer cancel()

domainID := "f1116985-d1f1-40e0-aba9-83344db915bc"
workflowExecution := gen.WorkflowExecution{WorkflowId: common.StringPtr("complete-decision-task-test"),
RunId: common.StringPtr("2aa0a74e-16ee-4f27-983d-48b07ec1915d")}
workflowExecution := types.WorkflowExecution{WorkflowID: common.StringPtr("complete-decision-task-test"),
RunID: common.StringPtr("2aa0a74e-16ee-4f27-983d-48b07ec1915d")}
taskList := "48b07ec1915d"
tasks0, err0 := s.CreateActivityTasks(ctx, domainID, workflowExecution, map[int64]string{
10: taskList,
Expand All @@ -222,8 +222,8 @@ func (s *MatchingPersistenceSuite) TestCompleteDecisionTask() {
s.Equal(5, len(tasksWithID1), "Expected 5 activity tasks.")
for _, t := range tasksWithID1 {
s.Equal(domainID, t.DomainID)
s.Equal(*workflowExecution.WorkflowId, t.WorkflowID)
s.Equal(*workflowExecution.RunId, t.RunID)
s.Equal(*workflowExecution.WorkflowID, t.WorkflowID)
s.Equal(*workflowExecution.RunID, t.RunID)
s.True(t.TaskID > 0)

err2 := s.CompleteTask(ctx, domainID, taskList, p.TaskListTypeActivity, t.TaskID, 100)
Expand All @@ -238,9 +238,9 @@ func (s *MatchingPersistenceSuite) TestCompleteTasksLessThan() {

domainID := uuid.New()
taskList := "range-complete-task-tl0"
wfExec := gen.WorkflowExecution{
WorkflowId: common.StringPtr("range-complete-task-test"),
RunId: common.StringPtr(uuid.New()),
wfExec := types.WorkflowExecution{
WorkflowID: common.StringPtr("range-complete-task-test"),
RunID: common.StringPtr(uuid.New()),
}
_, err := s.CreateActivityTasks(ctx, domainID, wfExec, map[int64]string{
10: taskList,
Expand Down
13 changes: 7 additions & 6 deletions common/persistence/persistence-tests/persistenceTestBase.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
"github.com/uber/cadence/common/persistence/sql"
"github.com/uber/cadence/common/service"
"github.com/uber/cadence/common/service/config"
"github.com/uber/cadence/common/types"
)

type (
Expand Down Expand Up @@ -1695,7 +1696,7 @@ func (s *TestBase) RangeCompleteTimerTask(ctx context.Context, inclusiveBeginTim
}

// CreateDecisionTask is a utility method to create a task
func (s *TestBase) CreateDecisionTask(ctx context.Context, domainID string, workflowExecution workflow.WorkflowExecution, taskList string,
func (s *TestBase) CreateDecisionTask(ctx context.Context, domainID string, workflowExecution types.WorkflowExecution, taskList string,
decisionScheduleID int64) (int64, error) {
leaseResponse, err := s.TaskMgr.LeaseTaskList(ctx, &p.LeaseTaskListRequest{
DomainID: domainID,
Expand All @@ -1713,8 +1714,8 @@ func (s *TestBase) CreateDecisionTask(ctx context.Context, domainID string, work
Execution: workflowExecution,
Data: &p.TaskInfo{
DomainID: domainID,
WorkflowID: *workflowExecution.WorkflowId,
RunID: *workflowExecution.RunId,
WorkflowID: *workflowExecution.WorkflowID,
RunID: *workflowExecution.RunID,
TaskID: taskID,
ScheduleID: decisionScheduleID,
},
Expand All @@ -1734,7 +1735,7 @@ func (s *TestBase) CreateDecisionTask(ctx context.Context, domainID string, work
}

// CreateActivityTasks is a utility method to create tasks
func (s *TestBase) CreateActivityTasks(ctx context.Context, domainID string, workflowExecution workflow.WorkflowExecution,
func (s *TestBase) CreateActivityTasks(ctx context.Context, domainID string, workflowExecution types.WorkflowExecution,
activities map[int64]string) ([]int64, error) {

taskLists := make(map[string]*p.TaskListInfo)
Expand All @@ -1760,8 +1761,8 @@ func (s *TestBase) CreateActivityTasks(ctx context.Context, domainID string, wor
Execution: workflowExecution,
Data: &p.TaskInfo{
DomainID: domainID,
WorkflowID: *workflowExecution.WorkflowId,
RunID: *workflowExecution.RunId,
WorkflowID: *workflowExecution.WorkflowID,
RunID: *workflowExecution.RunID,
TaskID: taskID,
ScheduleID: activityScheduleID,
ScheduleToStartTimeout: defaultScheduleToStartTimeout,
Expand Down
4 changes: 1 addition & 3 deletions common/persistence/taskManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ package persistence

import (
"context"

"github.com/uber/cadence/common/types/mapper/thrift"
)

type (
Expand Down Expand Up @@ -110,7 +108,7 @@ func (t *taskManager) toInternalCreateTaskInfo(createTaskInfo *CreateTaskInfo) *
return nil
}
return &InternalCreateTasksInfo{
Execution: *thrift.ToWorkflowExecution(&createTaskInfo.Execution),
Execution: createTaskInfo.Execution,
Data: t.toInternalTaskInfo(createTaskInfo.Data),
TaskID: createTaskInfo.TaskID,
}
Expand Down
4 changes: 2 additions & 2 deletions service/matching/matchingEngine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1920,10 +1920,10 @@ func (m *testTaskManager) CreateTasks(
scheduleID := task.Data.ScheduleID
info := &persistence.TaskInfo{
DomainID: domainID,
RunID: *task.Execution.RunId,
RunID: *task.Execution.RunID,
ScheduleID: scheduleID,
TaskID: task.TaskID,
WorkflowID: *task.Execution.WorkflowId,
WorkflowID: *task.Execution.WorkflowID,
}
if task.Data.ScheduleToStartTimeout != 0 {
info.Expiry = time.Now().Add(time.Duration(task.Data.ScheduleToStartTimeout) * time.Second)
Expand Down
3 changes: 1 addition & 2 deletions service/matching/taskWriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/uber/cadence/common/log/tag"
"github.com/uber/cadence/common/persistence"
"github.com/uber/cadence/common/types"
"github.com/uber/cadence/common/types/mapper/thrift"
)

type (
Expand Down Expand Up @@ -166,7 +165,7 @@ writerLoop:
for i, req := range reqs {
tasks = append(tasks, &persistence.CreateTaskInfo{
TaskID: taskIDs[i],
Execution: *thrift.FromWorkflowExecution(req.execution),
Execution: *req.execution,
Data: req.taskInfo,
})
maxReadLevel = taskIDs[i]
Expand Down