taskwatcher

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2024 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TaskWatcher

type TaskWatcher struct {
	Cron      *cron.Cron
	CronId    cron.EntryID
	RedisConn *redis.Client

	TaskPrefixKey          string // to seperate different task watcher
	UpdateOrphanedTaskCron string

	TickerDuration    time.Duration
	HeartbeatDuration time.Duration // heartbeat should longer than ticker to prevent redis transport speed too slow

	GetRunningTasksFunc  func() []string
	UpdateTaskToFailFunc func(id string, redisErr error)

	ErrorAfterStartTaskWatcher error
}

func NewTaskWatcher

func NewTaskWatcher(
	redisConn *redis.Client,
	updateOrphanedTaskCron,
	taskPrefixKey string,
	tickerDuration,
	heartbeatDuration time.Duration,
	getRunningTasksFunc func() []string,
	updateTaskToFailFunc func(id string, redisErr error),
) (taskWatcher TaskWatcher)

func (*TaskWatcher) CloseUpdateOrphanedTask

func (a *TaskWatcher) CloseUpdateOrphanedTask(uniqueKey string) (err error)

func (*TaskWatcher) StartTaskWatcher

func (a *TaskWatcher) StartTaskWatcher(uniqueKey string) (stopFunc func(), err error)

func (*TaskWatcher) StartUpdateOrphanedTask

func (a *TaskWatcher) StartUpdateOrphanedTask(uniqueKey string) (err error)

Jump to

Keyboard shortcuts

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