Skip to content

Commit

Permalink
Update SQL task manager to support sharded SQL DB (#4171)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaddoll committed Apr 30, 2021
1 parent fd38229 commit 4a71b12
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions common/persistence/sql/sqlTaskManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ func (m *sqlTaskManager) CreateTasks(
return nil, err
}
currTasksRow := sqlplugin.TasksRow{
ShardID: m.shardID(v.Data.DomainID, request.TaskListInfo.Name),
DomainID: serialization.MustParseUUID(v.Data.DomainID),
TaskListName: request.TaskListInfo.Name,
TaskType: int64(request.TaskListInfo.TaskType),
Expand Down Expand Up @@ -453,6 +454,7 @@ func (m *sqlTaskManager) GetTasks(
request *persistence.GetTasksRequest,
) (*persistence.InternalGetTasksResponse, error) {
rows, err := m.db.SelectFromTasks(ctx, &sqlplugin.TasksFilter{
ShardID: m.shardID(request.DomainID, request.TaskList),
DomainID: serialization.MustParseUUID(request.DomainID),
TaskListName: request.TaskList,
TaskType: int64(request.TaskType),
Expand Down Expand Up @@ -493,6 +495,7 @@ func (m *sqlTaskManager) CompleteTask(
taskID := request.TaskID
taskList := request.TaskList
_, err := m.db.DeleteFromTasks(ctx, &sqlplugin.TasksFilter{
ShardID: m.shardID(taskList.DomainID, taskList.Name),
DomainID: serialization.MustParseUUID(taskList.DomainID),
TaskListName: taskList.Name,
TaskType: int64(taskList.TaskType),
Expand All @@ -508,6 +511,7 @@ func (m *sqlTaskManager) CompleteTasksLessThan(
request *persistence.CompleteTasksLessThanRequest,
) (int, error) {
result, err := m.db.DeleteFromTasks(ctx, &sqlplugin.TasksFilter{
ShardID: m.shardID(request.DomainID, request.TaskListName),
DomainID: serialization.MustParseUUID(request.DomainID),
TaskListName: request.TaskListName,
TaskType: int64(request.TaskType),
Expand Down
2 changes: 2 additions & 0 deletions common/persistence/sql/sqlplugin/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ type (

// TasksRow represents a row in tasks table
TasksRow struct {
ShardID int
DomainID serialization.UUID
TaskType int64
TaskID int64
Expand Down Expand Up @@ -198,6 +199,7 @@ type (
// TasksFilter contains the column names within tasks table that
// can be used to filter results through a WHERE clause
TasksFilter struct {
ShardID int
DomainID serialization.UUID
TaskListName string
TaskType int64
Expand Down

0 comments on commit 4a71b12

Please sign in to comment.