tasks

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPingTask

func AddPingTask(clients []string, defaultOn bool, name string, target, task_type string, interval int, reference string) (uint, error)

AddPingTask 创建延迟监测任务。defaultOn 表示新加入的服务器是否自动开启此监测。

func AddPingTaskPinned added in v1.7.30

func AddPingTaskPinned(ctx context.Context, task *models.PingTask) error

AddPingTaskPinned creates a family-pinned task using the production DB and reloads the schedule after the transaction commits.

func AddPingTaskPinnedDraft added in v1.7.30

func AddPingTaskPinnedDraft(ctx context.Context, db *gorm.DB, task *models.PingTask, reload func() error) error

AddPingTaskPinnedDraft accepts an explicit DB and scheduler for isolated tests.

func AddPingTaskWithOptions added in v1.8.0

func AddPingTaskWithOptions(clients []string, defaultOn bool, name string, target, taskType string, interval int, reference string, opts PingTaskOptions) (uint, error)

AddPingTaskWithOptions creates a task with the additive probe settings. It is the only legacy-path constructor that writes the v1.8 columns.

func ClearTaskResultsByTimeBefore

func ClearTaskResultsByTimeBefore(before time.Time) error

func CreateClientWithDefaultPing added in v1.7.30

func CreateClientWithDefaultPing(ctx context.Context, db *gorm.DB, client *models.Client) (bool, error)

CreateClientWithDefaultPing atomically creates a node and its default-on assignments. The caller holds the roster fence and the new node's guard; task creation/edit takes the same roster fence before node/task guards.

func CreateTask

func CreateTask(taskId string, clients []string, command string) error

func DeleteAllPingRecords

func DeleteAllPingRecords() error

func DeletePingRecords

func DeletePingRecords(id []uint) error

func DeletePingTask

func DeletePingTask(id []uint) error

func EditPingTask

func EditPingTask(edits []PingTaskEdit) error

EditPingTask 批量更新延迟监测任务配置。

func EditPingTasksPinnedDraft added in v1.7.30

func EditPingTasksPinnedDraft(ctx context.Context, db *gorm.DB, edits []PingTaskEdit, reload func() error) error

EditPingTasksPinnedDraft accepts an explicit DB and scheduler for isolated tests.

func GetAllPingTasks

func GetAllPingTasks() ([]models.PingTask, error)

func GetAllTasks

func GetAllTasks() ([]models.Task, error)

func GetPingRecords

func GetPingRecords(uuid string, taskId int, start, end time.Time) ([]models.PingRecord, error)

func GetPingRecordsBatch added in v0.1.16

func GetPingRecordsBatch(uuids []string, taskId int, start, end time.Time) (map[string][]models.PingRecord, error)

GetPingRecordsBatch 一次查询取回多个节点的 ping 记录(见 metricstore 里的说明)。

func GetPingTasksByClient

func GetPingTasksByClient(uuid string) []models.PingTask

GetPingTasksByClient 获取指定服务器需要执行的延迟监测任务。

func GetSpecificTaskResult

func GetSpecificTaskResult(taskId, clientId string) (*models.TaskResult, error)

func GetTaskByTaskId

func GetTaskByTaskId(taskId string) (*models.Task, error)

func GetTaskResultsByTaskId

func GetTaskResultsByTaskId(taskId string) ([]models.TaskResult, error)

func GetTasksByClientId

func GetTasksByClientId(clientId string) ([]models.Task, error)

func PingScheduleReloadPending added in v1.7.30

func PingScheduleReloadPending() bool

PingScheduleReloadPending reports whether the last complete reload failed. It does not prove individual probes are executing successfully.

func ReconcilePingDeletions added in v1.7.30

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

ReconcilePingDeletions retries a bounded batch after a crash or failed metric cleanup. All supported task creation paths must reject reserved IDs.

func ReconcilePingSchedule added in v1.7.30

func ReconcilePingSchedule() (bool, error)

ReconcilePingSchedule retries a failed reload without disturbing healthy timers. Startup performs an ordinary reload, so a restart cannot clear a failure without attempting to load the persisted configuration again.

func ReloadPingSchedule

func ReloadPingSchedule() error

func SaveTaskResult

func SaveTaskResult(taskId, clientId, result string, exitCode int, timestamp time.Time) error

func SaveTaskResultContext added in v1.7.0

func SaveTaskResultContext(ctx context.Context, taskId, clientId, result string, exitCode int, timestamp time.Time) error

func UpdatePingTaskOrder

func UpdatePingTaskOrder(order map[uint]int) error

func ValidateProbeOptions added in v1.8.0

func ValidateProbeOptions(task *models.PingTask) error

ValidateProbeOptions validates the additive v1.8 probe fields. Zero/empty is the legacy single-probe behavior and is always valid.

Types

type PingDeletionPendingError added in v1.7.30

type PingDeletionPendingError struct{ Err error }

PingDeletionPendingError means the tasks are already deleted. Their IDs remain reserved after historical metric cleanup or schedule reload retries.

func (*PingDeletionPendingError) Error added in v1.7.30

func (e *PingDeletionPendingError) Error() string

func (*PingDeletionPendingError) Unwrap added in v1.7.30

func (e *PingDeletionPendingError) Unwrap() error

type PingTaskEdit added in v1.7.30

type PingTaskEdit struct {
	Task      *models.PingTask
	Reference *string
	Family    *string
}

PingTaskEdit distinguishes omitted optional fields from explicit clears.

type PingTaskOptions added in v1.8.0

type PingTaskOptions struct {
	ProbeAttempts       int
	ProbeSpacingMS      int
	ProbeTimeoutMS      int
	HTTPMode            string
	HTTPExpectedStatus  string
	IPVersionPreference string
}

PingTaskOptions carries the additive v1.8 probe settings. The zero value is the legacy single-probe behavior, so existing callers are unchanged.

type PingTaskValidationError added in v1.7.30

type PingTaskValidationError struct{ Err error }

func (*PingTaskValidationError) Error added in v1.7.30

func (e *PingTaskValidationError) Error() string

func (*PingTaskValidationError) Unwrap added in v1.7.30

func (e *PingTaskValidationError) Unwrap() error

type ScheduleReloadPendingError added in v1.7.30

type ScheduleReloadPendingError struct {
	TaskID uint
	Err    error
}

ScheduleReloadPendingError means the database mutation has already committed. Callers must not retry a create blindly: TaskID identifies the saved task, while the schedule still needs reconciliation.

func (*ScheduleReloadPendingError) Error added in v1.7.30

func (*ScheduleReloadPendingError) Unwrap added in v1.7.30

func (e *ScheduleReloadPendingError) Unwrap() error

Jump to

Keyboard shortcuts

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