observer

package
v1.99.99 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2021 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventType

type EventType string

EventType describes an event for the observer

const (
	Update    EventType = "update"
	Delete    EventType = "delete"
	Create    EventType = "create"
	Failed    EventType = "failed"
	Succeeded EventType = "succeeded"
	Running   EventType = "running"
)

type ObservableJob

type ObservableJob struct {
	Job        *batchv1.Job
	JobType    v1alpha1.JobType
	Event      EventType
	Exclusive  bool
	Repository string
	// contains filtered or unexported fields
}

ObservableJob defines a batchv1.job that is being observed by the Observer.

type ObservableJobCallback

type ObservableJobCallback func(ObservableJob)

ObservableJobCallback is invoked on certain events of the ObservableJob. The related ObservableJob is passed as argument. Check the ObservableJob.Event property if you need to know the exact event on which your ObservableJobCallback was invoked.

type Observer

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

Observer handles the internal state of the observed batchv1.job objects.

func GetObserver

func GetObserver() *Observer

GetObserver returns the currently active observer

func (*Observer) GetJobByName

func (o *Observer) GetJobByName(jobName string) ObservableJob

GetJobByName will return the requested job if it exists. JobName needs to be a string in the form of `jobname/namespace`

func (*Observer) GetJobsByRepository

func (o *Observer) GetJobsByRepository(repository string) []ObservableJob

GetJobsByRepository will return a list of all the jobs currently being observed in a given repository.

func (*Observer) GetUpdateChannel

func (o *Observer) GetUpdateChannel() chan ObservableJob

GetUpdateChannel returns a chan ObservableJob. This channel allows for adding or updating jobs that are observed.

func (*Observer) IsAnyJobRunning

func (o *Observer) IsAnyJobRunning(repository string) bool

IsAnyJobRunning will return true if there's any job running for the given repository.

func (*Observer) IsConcurrentJobsLimitReached

func (o *Observer) IsConcurrentJobsLimitReached(jobType v1alpha1.JobType, limit int) bool

IsConcurrentJobsLimitReached checks if the limit of concurrent jobs by type (backup, check, etc) has been reached

func (*Observer) IsExclusiveJobRunning

func (o *Observer) IsExclusiveJobRunning(repository string) bool

IsExclusiveJobRunning will return true if there's currently an exclusive job running on the repository.

func (*Observer) RegisterCallback

func (o *Observer) RegisterCallback(name string, callback ObservableJobCallback)

RegisterCallback will register a function to the given observed job. The callbacks will be executed if the job is successful, failed or deleted.

Jump to

Keyboard shortcuts

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