dispatcher

package
v0.0.0-...-503c688 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultSubtaskConcurrency is the default concurrency for handling subtask.
	DefaultSubtaskConcurrency = 16
	// MaxSubtaskConcurrency is the maximum concurrency for handling subtask.
	MaxSubtaskConcurrency = 256
)

Variables

View Source
var (
	// DefaultDispatchConcurrency is the default concurrency for handling global task.
	DefaultDispatchConcurrency = 4
)

Functions

func ClearTaskFlowHandle

func ClearTaskFlowHandle()

ClearTaskFlowHandle is only used in test

func GenerateSchedulerNodes

func GenerateSchedulerNodes(ctx context.Context) ([]*infosync.ServerInfo, error)

GenerateSchedulerNodes generate a eligible TiDB nodes.

func GetEligibleInstance

func GetEligibleInstance(serverNodes []*infosync.ServerInfo, pos int) (string, error)

GetEligibleInstance gets an eligible instance.

func RegisterTaskFlowHandle

func RegisterTaskFlowHandle(taskType string, dispatcherHandle TaskFlowHandle)

RegisterTaskFlowHandle is used to register the global task handle.

Types

type Dispatch

type Dispatch interface {
	// Start enables dispatching and monitoring mechanisms.
	Start()
	// GetAllSchedulerIDs gets handles the task's all available instances.
	GetAllSchedulerIDs(ctx context.Context, gTaskID int64) ([]string, error)
	// Stop stops the dispatcher.
	Stop()
}

Dispatch defines the interface for operations inside a dispatcher.

func NewDispatcher

func NewDispatcher(ctx context.Context, taskTable *storage.TaskManager) (Dispatch, error)

NewDispatcher creates a dispatcher struct.

type MockHandle

type MockHandle struct {
	mock.Mock
}

MockHandle is used to mock the Handle.

func (*MockHandle) GetAllSchedulerIDs

func (m *MockHandle) GetAllSchedulerIDs(ctx context.Context, gTaskID int64) ([]string, error)

GetAllSchedulerIDs implements the Handle.GetAllSchedulerIDs interface.

type TaskFlowHandle

type TaskFlowHandle interface {
	ProcessNormalFlow(ctx context.Context, h TaskHandle, gTask *proto.Task) (metas [][]byte, err error)
	ProcessErrFlow(ctx context.Context, h TaskHandle, gTask *proto.Task, receiveErr [][]byte) (meta []byte, err error)
}

TaskFlowHandle is used to control the process operations for each global task.

func GetTaskFlowHandle

func GetTaskFlowHandle(taskType string) TaskFlowHandle

GetTaskFlowHandle is used to get the global task handle.

type TaskHandle

type TaskHandle interface {
	// GetAllSchedulerIDs gets handles the task's all scheduler instances.
	GetAllSchedulerIDs(ctx context.Context, gTaskID int64) ([]string, error)
}

TaskHandle provides the interface for operations needed by task flow handles.

Jump to

Keyboard shortcuts

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