tasks

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: Apache-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 KeyWorkers

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

func (*KeyWorkers) Init

func (s *KeyWorkers) Init(name string, workFunc WorkFunc)

func (*KeyWorkers) NeedsWork

func (s *KeyWorkers) NeedsWork(ctx context.Context, key interface{}) chan struct{}

func (*KeyWorkers) Pause

func (s *KeyWorkers) Pause()

func (*KeyWorkers) Resume

func (s *KeyWorkers) Resume()

func (*KeyWorkers) WaitIdle

func (s *KeyWorkers) WaitIdle()

WaitIdle waits until there are no workers. Mostly for unit testing.

func (*KeyWorkers) WorkerCount

func (s *KeyWorkers) WorkerCount() int

type PeriodicTask

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

PeriodicTask is a task manager that controls a go routine which periodically runs some task function. The task can be run on demand, or the manager can be stopped and restarted.

func NewPeriodicTask

func NewPeriodicTask(task PeriodicTaskable) *PeriodicTask

func (*PeriodicTask) Start

func (s *PeriodicTask) Start()

func (*PeriodicTask) Stop

func (s *PeriodicTask) Stop()

func (*PeriodicTask) Wakeup

func (s *PeriodicTask) Wakeup()

Wakeup causes the task to be run immediately

type PeriodicTaskable

type PeriodicTaskable interface {
	// Task function to run
	Run(ctx context.Context)
	// Interval between runs (changes do not apply until the next iteration)
	GetInterval() time.Duration
	// Starts a span for the task
	StartSpan() opentracing.Span
}

PeriodicTaskable is a task that continuously runs at a set time interval. This informs the PeriodicTask when to run again, and what the span context should be for each run.

type WorkFunc

type WorkFunc func(ctx context.Context, key interface{})

Jump to

Keyboard shortcuts

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