component

package
v6.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Clock = clock.NewClock()

Functions

This section is empty.

Types

type Component

type Component interface {
	Name() string
	Paused() bool

	IntervalElapsed() bool

	Reload() (bool, error)
	UpdateLastRan() error
}

type Coordinator

type Coordinator struct {
	Locker    lock.LockFactory
	Component Component
	Runnable  Runnable
}

Coordinator ensures that the given component is not executed concurrently.

func (*Coordinator) RunImmediately

func (coordinator *Coordinator) RunImmediately(ctx context.Context)

func (*Coordinator) RunPeriodically

func (coordinator *Coordinator) RunPeriodically(ctx context.Context)

type Drainable

type Drainable interface {
	// Drain is invoked on shutdown.
	Drain(context.Context)
}

Drainable is an optional interface which component runners can implement in order to perform something on shutdown.

type NotificationsBus

type NotificationsBus interface {
	Listen(string) (chan bool, error)
	Unlisten(string, chan bool) error
}

type RunFunc

type RunFunc func(context.Context) error

RunFunc turns a simple function into a Runnable.

func (RunFunc) Run

func (f RunFunc) Run(ctx context.Context) error

type Runnable

type Runnable interface {
	// Run is invoked repeatedly. The component should perform whatever work is
	// available and return.
	Run(context.Context) error
}

Runnable represents a workload to execute.

type Runner

type Runner struct {
	Logger lager.Logger

	Interval  time.Duration
	Component Component
	Bus       NotificationsBus

	Schedulable Schedulable
}

Runner runs a workload periodically, or immediately upon receiving a notification.

func (*Runner) Run

func (scheduler *Runner) Run(signals <-chan os.Signal, ready chan<- struct{}) error

type Schedulable

type Schedulable interface {
	RunPeriodically(context.Context)
	RunImmediately(context.Context)
}

Schedulable represents a workload that is executed normally on a periodic schedule, but can also be run immediately.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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