coordinator

package
v1.7.6 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultLimit = 1000

DefaultLimit is the maximum number of tasks that a given taskd server can own

Variables

This section is empty.

Functions

This section is empty.

Types

type Coordinator

type Coordinator struct {
	// contains filtered or unexported fields
}

Coordinator is the intermediary between the scheduling/executing system and the rest of the task system

func NewCoordinator

func NewCoordinator(log *zap.Logger, scheduler scheduler.Scheduler, executor Executor, opts ...CoordinatorOption) *Coordinator

func (*Coordinator) RunCancelled

func (c *Coordinator) RunCancelled(ctx context.Context, runID platform.ID) error

RunCancelled speaks directly to the executor to cancel a task run

func (*Coordinator) RunForced

func (c *Coordinator) RunForced(ctx context.Context, task *taskmodel.Task, run *taskmodel.Run) error

RunForced speaks directly to the Executor to run a task immediately

func (*Coordinator) RunRetried

func (c *Coordinator) RunRetried(ctx context.Context, task *taskmodel.Task, run *taskmodel.Run) error

RunRetried speaks directly to the executor to re-try a task run immediately

func (*Coordinator) TaskCreated

func (c *Coordinator) TaskCreated(ctx context.Context, task *taskmodel.Task) error

TaskCreated asks the scheduler to schedule the newly created task

func (*Coordinator) TaskDeleted

func (c *Coordinator) TaskDeleted(ctx context.Context, id platform.ID) error

TaskDeleted asks the scheduler to release the deleted task

func (*Coordinator) TaskUpdated

func (c *Coordinator) TaskUpdated(ctx context.Context, from, to *taskmodel.Task) error

TaskUpdated releases the task if it is being disabled, and schedules it otherwise

type CoordinatorOption

type CoordinatorOption func(*Coordinator)

func WithLimitOpt

func WithLimitOpt(i int) CoordinatorOption

type Executor

type Executor interface {
	ManualRun(ctx context.Context, id platform.ID, runID platform.ID) (executor.Promise, error)
	Cancel(ctx context.Context, runID platform.ID) error
}

Executor is an abstraction of the task executor with only the functions needed by the coordinator

type SchedulableTask

type SchedulableTask struct {
	*taskmodel.Task
	// contains filtered or unexported fields
}

SchedulableTask is a wrapper around the Task struct, giving it methods to make it compatible with the scheduler

func NewSchedulableTask

func NewSchedulableTask(task *taskmodel.Task) (SchedulableTask, error)

NewSchedulableTask transforms an influxdb task to a schedulable task type

func (SchedulableTask) ID

func (t SchedulableTask) ID() scheduler.ID

func (SchedulableTask) LastScheduled

func (t SchedulableTask) LastScheduled() time.Time

LastScheduled parses the task's LatestCompleted value as a Time object

func (SchedulableTask) Offset

func (t SchedulableTask) Offset() time.Duration

Offset returns a time.Duration for the Task's offset property

func (SchedulableTask) Schedule

func (t SchedulableTask) Schedule() scheduler.Schedule

Schedule takes the time a Task is scheduled for and returns a Schedule object

Jump to

Keyboard shortcuts

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