handle

package
v0.0.0-...-f8535f3 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// TaskChangedCh used to speed up task schedule, such as when task is submitted
	// in the same node as the scheduler manager.
	// put it here to avoid cyclic import.
	TaskChangedCh = make(chan struct{}, 1)
)

Functions

func CalculateNodeResource

func CalculateNodeResource() (*proto.NodeResource, error)

CalculateNodeResource calculates the node resource.

func CancelTask

func CancelTask(ctx context.Context, taskKey string) error

CancelTask cancels a task.

func GetCPUCountOfNode

func GetCPUCountOfNode(ctx context.Context) (int, error)

GetCPUCountOfNode gets the CPU count of the managed node.

func GetNodeResource

func GetNodeResource() *proto.NodeResource

GetNodeResource gets the node resource.

func NotifyTaskChange

func NotifyTaskChange()

NotifyTaskChange is used to notify the scheduler manager that the task is changed, either a new task is submitted or a task is finished.

func PauseTask

func PauseTask(ctx context.Context, taskKey string) error

PauseTask pauses a task.

func ResumeTask

func ResumeTask(ctx context.Context, taskKey string) error

ResumeTask resumes a task.

func RunWithRetry

func RunWithRetry(
	ctx context.Context,
	maxRetry int,
	backoffer backoff.Backoffer,
	logger *zap.Logger,
	f func(context.Context) (bool, error),
) error

RunWithRetry runs a function with retry, when retry exceed max retry time, it returns the last error met. if the function fails with err, it should return a bool to indicate whether the error is retryable. if context done, it will stop early and return ctx.Err().

func SetNodeResource

func SetNodeResource(rc *proto.NodeResource)

SetNodeResource gets the node resource.

func SubmitTask

func SubmitTask(ctx context.Context, taskKey string, taskType proto.TaskType, concurrency int, targetScope string, taskMeta []byte) (*proto.Task, error)

SubmitTask submits a task.

func WaitTask

func WaitTask(ctx context.Context, id int64, matchFn func(base *proto.TaskBase) bool) (*proto.TaskBase, error)

WaitTask waits for a task until it meets the matchFn.

func WaitTaskDoneByKey

func WaitTaskDoneByKey(ctx context.Context, taskKey string) error

WaitTaskDoneByKey waits for a task done by task key.

func WaitTaskDoneOrPaused

func WaitTaskDoneOrPaused(ctx context.Context, id int64) error

WaitTaskDoneOrPaused waits for a task done or paused. this API returns error if task failed or cancelled.

Types

This section is empty.

Jump to

Keyboard shortcuts

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