tasks

package
v0.0.0-...-c61326f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2025 License: PostgreSQL Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TaskPlanned = iota
	TaskSplit
	TaskMoved
)
View Source
const (
	JoinNone = iota
	JoinLeft
	JoinRight
)
View Source
const (
	SplitLeft = iota
	SplitRight
)
View Source
const (
	RedistributeTaskPlanned = iota
	RedistributeTaskMoved
)
View Source
const (
	BalancerTaskPlanned = iota
	BalancerTaskMoved
)

Variables

This section is empty.

Functions

func BalancerTaskStateToProto

func BalancerTaskStateToProto(state BalancerTaskState) protos.BalancerTaskStatus

func BalancerTaskToDb

func BalancerTaskToDb(task *BalancerTask) *qdb.BalancerTask

func BalancerTaskToProto

func BalancerTaskToProto(task *BalancerTask) *protos.BalancerTask

func JoinTypeToProto

func JoinTypeToProto(t JoinType) protos.JoinType

JoinTypeToProto converts a JoinType to its corresponding protos.JoinType. It takes a JoinType as input and returns the corresponding protos.JoinType. If the input JoinType is not recognized, it panics with an "incorrect join type" error.

Parameters:

  • t: The JoinType value to convert.

Returns:

  • protos.JoinType: The converted protos.JoinType value.

func RedistributeTaskStateToProto

func RedistributeTaskStateToProto(state RedistributeTaskState) protos.RedistributeTaskState

func RedistributeTaskToDB

func RedistributeTaskToDB(task *RedistributeTask) *qdb.RedistributeTask

func RedistributeTaskToProto

func RedistributeTaskToProto(task *RedistributeTask) *protos.RedistributeTask

func SplitTypeToProto

func SplitTypeToProto(t SplitType) protos.SplitType

SplitTypeToProto converts a SplitType to its corresponding protos.SplitType. It takes a SplitType as input and returns the corresponding protos.SplitType. If the input SplitType is not recognized, it panics with an "incorrect split type" error.

Parameters:

  • t: The SplitType value to convert.

Returns:

  • protos.SplitType: The converted protos.SplitType value.

func TaskGroupToDb

func TaskGroupToDb(group *MoveTaskGroup) *qdb.MoveTaskGroup

TaskGroupToDb converts a MoveTaskGroup object to a qdb.MoveTaskGroup object. It creates a new qdb.MoveTaskGroup object and populates its fields based on the provided MoveTaskGroup object. The Tasks field is populated by converting each MoveTask object in the group.Tasks slice to a qdb.MoveTask object using the TaskToDb function. The JoinType field is set to the integer value of the group.JoinType. The converted qdb.MoveTaskGroup object is returned.

Parameters:

  • group: The MoveTaskGroup object to convert.

Returns:

  • *qdb.MoveTaskGroup: The converted qdb.MoveTaskGroup object.

func TaskGroupToProto

func TaskGroupToProto(group *MoveTaskGroup) *protos.MoveTaskGroup

TaskGroupToProto converts a MoveTaskGroup object to its corresponding protobuf representation. It creates a new protos.MoveTaskGroup object and copies the values from the input object to the output object.

Parameters:

  • group: The MoveTaskGroup object to convert.

Returns:

  • *protos.MoveTaskGroup: The converted protos.MoveTaskGroup object.

func TaskStateToProto

func TaskStateToProto(state TaskState) protos.TaskStatus

TaskStateToProto converts a TaskState value to its corresponding protos.TaskStatus value. It takes a TaskState as input and returns the corresponding protos.TaskStatus value. If the input TaskState is not recognized, it panics with an "incorrect task state" error.

Parameters:

  • state: The TaskState value to convert.

Returns:

  • protos.TaskStatus: The converted protos.TaskStatus value.

func TaskStateToStr

func TaskStateToStr(state TaskState) string

TaskStateToStr converts a TaskState value to its corresponding string representation. It takes a TaskState as input and returns the corresponding string representation. If the input TaskState is not recognized, it panics with an "incorrect task state" error.

Parameters:

  • state: The TaskState value to convert.

Returns:

  • string: The string representation of the TaskState value.

func TaskToDb

func TaskToDb(task *MoveTask) *qdb.MoveTask

TaskToDb converts a MoveTask struct to a qdb.MoveTask struct. It takes a pointer to a MoveTask struct as input and returns a pointer to a qdb.MoveTask struct. The function creates a new qdb.MoveTask object and copies the values from the input MoveTask object to the output qdb.MoveTask object.

Parameters:

  • task: The MoveTask object to convert.

Returns:

  • *qdb.MoveTask: The converted qdb.MoveTask object.

func TaskToProto

func TaskToProto(task *MoveTask) *protos.MoveTask

TaskToProto converts a MoveTask struct to a protos.MoveTask struct. It creates a new protos.MoveTask object and copies the values from the input object to the output object.

Parameters:

  • task: The MoveTask object to convert.

Returns:

  • *protos.MoveTask: The converted protos.MoveTask object.

Types

type BalancerTask

type BalancerTask struct {
	Type      JoinType
	KrIdFrom  string
	KrIdTo    string
	KrIdTemp  string
	ShardIdTo string
	KeyCount  int64
	State     BalancerTaskState
}

func BalancerTaskFromDb

func BalancerTaskFromDb(task *qdb.BalancerTask) *BalancerTask

func BalancerTaskFromProto

func BalancerTaskFromProto(task *protos.BalancerTask) *BalancerTask

type BalancerTaskState

type BalancerTaskState int

func BalancerTaskStateFromProto

func BalancerTaskStateFromProto(state protos.BalancerTaskStatus) BalancerTaskState

type JoinType

type JoinType int

func JoinTypeFromProto

func JoinTypeFromProto(t protos.JoinType) JoinType

JoinTypeFromProto converts a protos.JoinType to a JoinType. It maps the given protos.JoinType to the corresponding JoinType value. If the given protos.JoinType is not recognized, it panics with an "incorrect join type" error.

Parameters:

  • t: The protos.JoinType value to convert.

Returns:

  • JoinType: The converted JoinType value.

type MoveTask

type MoveTask struct {
	Bound    [][]byte
	KrIdTemp string
	State    TaskState
}

func TaskFromDb

func TaskFromDb(task *qdb.MoveTask) *MoveTask

TaskFromDb converts a qdb.MoveTask object to a MoveTask object. It takes a pointer to a qdb.MoveTask as input and returns a pointer to a MoveTask. The function creates a new MoveTask object and copies the values from the input qdb.MoveTask object to the output MoveTask object.

Parameters:

  • task: The qdb.MoveTask object to convert.

Returns:

  • *MoveTask: The converted MoveTask object.

func TaskFromProto

func TaskFromProto(task *protos.MoveTask) *MoveTask

TaskFromProto converts a protos.MoveTask object to a MoveTask object. It creates a new MoveTask object and copies the values from the input object to the output object.

Parameters:

  • task: The protos.MoveTask object to convert.

Returns:

  • *MoveTask: The converted MoveTask object.

type MoveTaskGroup

type MoveTaskGroup struct {
	ShardToId string
	KrIdFrom  string
	KrIdTo    string
	Tasks     []*MoveTask
	Type      SplitType
}

func TaskGroupFromDb

func TaskGroupFromDb(group *qdb.MoveTaskGroup) *MoveTaskGroup

TaskGroupFromDb converts a database task group to a MoveTaskGroup struct. It takes a pointer to a qdb.MoveTaskGroup as input and returns a pointer to a MoveTaskGroup. The function creates a new MoveTaskGroup object and populates its fields based on the provided qdb.MoveTaskGroup object. The Tasks field is populated by converting each qdb.MoveTask object in the group.Tasks slice to a MoveTask object using the TaskFromDb function. The JoinType field is set to the JoinType value of the qdb.MoveTaskGroup object.

Parameters:

  • group: The qdb.MoveTaskGroup object to convert.

Returns:

  • *MoveTaskGroup: The converted MoveTaskGroup object.

func TaskGroupFromProto

func TaskGroupFromProto(group *protos.MoveTaskGroup) *MoveTaskGroup

TaskGroupFromProto converts a protos.MoveTaskGroup object to a MoveTaskGroup object. It creates a new MoveTaskGroup object and copies the values from the input object to the output object.

Parameters:

  • group: The protos.MoveTaskGroup object to convert.

Returns:

  • *MoveTaskGroup: The converted MoveTaskGroup object.

type RedistributeTask

type RedistributeTask struct {
	KrId      string
	ShardId   string
	BatchSize int
	TempKrId  string
	State     RedistributeTaskState
}

func RedistributeTaskFromDB

func RedistributeTaskFromDB(task *qdb.RedistributeTask) *RedistributeTask

func RedistributeTaskFromProto

func RedistributeTaskFromProto(task *protos.RedistributeTask) *RedistributeTask

type RedistributeTaskState

type RedistributeTaskState int

func RedistributeTaskStateFromProto

func RedistributeTaskStateFromProto(state protos.RedistributeTaskState) RedistributeTaskState

type SplitType

type SplitType int

func SplitTypeFromProto

func SplitTypeFromProto(t protos.SplitType) SplitType

SplitTypeFromProto converts a protos.JoinType to a SplitType. It maps the given protos.SplitType to the corresponding SplitType value. If the given protos.SplitType is not recognized, it panics with an "incorrect split type" error.

Parameters:

  • t: The protos.SplitType value to convert.

Returns:

  • SplitType: The converted SplitType value.

type TaskMgr

type TaskMgr interface {
	GetMoveTaskGroup(ctx context.Context) (*MoveTaskGroup, error)
	WriteMoveTaskGroup(ctx context.Context, taskGroup *MoveTaskGroup) error
	RemoveMoveTaskGroup(ctx context.Context) error

	GetBalancerTask(ctx context.Context) (*BalancerTask, error)
	WriteBalancerTask(ctx context.Context, task *BalancerTask) error
	RemoveBalancerTask(ctx context.Context) error
}

type TaskState

type TaskState int

func TaskStateFromProto

func TaskStateFromProto(state protos.TaskStatus) TaskState

TaskStateFromProto converts a protos.TaskStatus value to a TaskState value. It maps the given protos.TaskStatus to the corresponding TaskState value. If the given protos.TaskStatus is not recognized, it panics with an "incorrect task state" error.

Parameters:

  • state: The protos.TaskStatus value to convert.

Returns:

  • TaskState: The converted TaskState value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL