scheduledtask

package
v0.166.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package scheduledtask implements a task scheduler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DAL added in v0.104.1

type DAL interface {
	GetControllers(ctx context.Context, all bool) ([]dal.Controller, error)
}

type DALFunc added in v0.104.1

type DALFunc func(ctx context.Context, all bool) ([]dal.Controller, error)

func (DALFunc) GetControllers added in v0.104.1

func (f DALFunc) GetControllers(ctx context.Context, all bool) ([]dal.Controller, error)

type Job

type Job func(ctx context.Context) (time.Duration, error)

A Job is a function that is scheduled to run periodically.

The Job itself controls its schedule by returning the next time it should run.

type Scheduler

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

Scheduler is a task scheduler for the controller.

Each job runs in its own goroutine.

The scheduler uses a consistent hash ring to attempt to ensure that jobs are only run on a single controller at a time. This is not guaranteed, however, as the hash ring is only updated periodically and controllers may have inconsistent views of the hash ring.

func New

func New(ctx context.Context, id model.ControllerKey, controller DAL) *Scheduler

New creates a new Scheduler.

func NewForTesting added in v0.104.1

func NewForTesting(ctx context.Context, id model.ControllerKey, controller DAL, clock clock.Clock) *Scheduler

func (*Scheduler) Parallel

func (s *Scheduler) Parallel(retry backoff.Backoff, job Job)

Parallel schedules a job to run on every controller.

func (*Scheduler) Singleton

func (s *Scheduler) Singleton(retry backoff.Backoff, job Job)

Singleton schedules a job to attempt to run on only a single controller.

This is not guaranteed, however, as controllers may have inconsistent views of the hash ring.

Jump to

Keyboard shortcuts

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