jobs

package
v6.0.0-...-cfe9101 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: AGPL-3.0, Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CancelWatcherPollingInterval = 5000
)

Variables

View Source
var (
	ErrSchedulersNotRunning    = errors.New("job schedulers are not running")
	ErrSchedulersRunning       = errors.New("job schedulers are running")
	ErrSchedulersUninitialized = errors.New("job schedulers are not initialized")
)
View Source
var (
	ErrWorkersNotRunning    = errors.New("job workers are not running")
	ErrWorkersRunning       = errors.New("job workers are running")
	ErrWorkersUninitialized = errors.New("job workers are not initialized")
)
View Source
var DefaultWatcherPollingInterval = 15000

Default polling interval for jobs termination. (Defining as `var` rather than `const` allows tests to lower the interval.)

Functions

func GenerateNextStartDateTime

func GenerateNextStartDateTime(now time.Time, nextStartTime time.Time) *time.Time

Types

type DailyScheduler

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

func NewDailyScheduler

func NewDailyScheduler(jobs *JobServer, jobType string, startTimeFunc func(cfg *model.Config) *time.Time, enabledFunc func(cfg *model.Config) bool) *DailyScheduler

func (*DailyScheduler) Enabled

func (scheduler *DailyScheduler) Enabled(cfg *model.Config) bool

func (*DailyScheduler) NextScheduleTime

func (scheduler *DailyScheduler) NextScheduleTime(cfg *model.Config, now time.Time, _ bool, _ *model.Job) *time.Time

func (*DailyScheduler) ScheduleJob

func (scheduler *DailyScheduler) ScheduleJob(_ *model.Config, _ bool, _ *model.Job) (*model.Job, *model.AppError)

type JobServer

type JobServer struct {
	ConfigService configservice.ConfigService
	Store         store.Store
	// contains filtered or unexported fields
}

func NewJobServer

func NewJobServer(configService configservice.ConfigService, store store.Store, metrics einterfaces.MetricsInterface) *JobServer

func (*JobServer) CancellationWatcher

func (srv *JobServer) CancellationWatcher(ctx context.Context, jobId string, cancelChan chan struct{})

func (*JobServer) CheckForPendingJobsByType

func (srv *JobServer) CheckForPendingJobsByType(jobType string) (bool, *model.AppError)

func (*JobServer) ClaimJob

func (srv *JobServer) ClaimJob(job *model.Job) (bool, *model.AppError)

func (*JobServer) Config

func (srv *JobServer) Config() *model.Config

func (*JobServer) CreateJob

func (srv *JobServer) CreateJob(jobType string, jobData map[string]string) (*model.Job, *model.AppError)

func (*JobServer) GetJob

func (srv *JobServer) GetJob(id string) (*model.Job, *model.AppError)

func (*JobServer) GetJobsByTypeAndStatus

func (srv *JobServer) GetJobsByTypeAndStatus(jobType string, status string) ([]*model.Job, *model.AppError)

func (*JobServer) GetLastSuccessfulJobByType

func (srv *JobServer) GetLastSuccessfulJobByType(jobType string) (*model.Job, *model.AppError)

func (*JobServer) HandleClusterLeaderChange

func (srv *JobServer) HandleClusterLeaderChange(isLeader bool)

func (*JobServer) MakeWatcher

func (srv *JobServer) MakeWatcher(workers *Workers, pollingInterval int) *Watcher

func (*JobServer) RegisterJobType

func (srv *JobServer) RegisterJobType(name string, worker model.Worker, scheduler model.Scheduler)

func (*JobServer) RequestCancellation

func (srv *JobServer) RequestCancellation(jobId string) *model.AppError

func (*JobServer) SetJobCanceled

func (srv *JobServer) SetJobCanceled(job *model.Job) *model.AppError

func (*JobServer) SetJobError

func (srv *JobServer) SetJobError(job *model.Job, jobError *model.AppError) *model.AppError

func (*JobServer) SetJobPending

func (srv *JobServer) SetJobPending(job *model.Job) *model.AppError

func (*JobServer) SetJobProgress

func (srv *JobServer) SetJobProgress(job *model.Job, progress int64) *model.AppError

func (*JobServer) SetJobSuccess

func (srv *JobServer) SetJobSuccess(job *model.Job) *model.AppError

func (*JobServer) SetJobWarning

func (srv *JobServer) SetJobWarning(job *model.Job) *model.AppError

func (*JobServer) StartSchedulers

func (srv *JobServer) StartSchedulers() error

func (*JobServer) StartWorkers

func (srv *JobServer) StartWorkers() error

func (*JobServer) StopSchedulers

func (srv *JobServer) StopSchedulers() error

func (*JobServer) StopWorkers

func (srv *JobServer) StopWorkers() error

func (*JobServer) UpdateInProgressJobData

func (srv *JobServer) UpdateInProgressJobData(job *model.Job) *model.AppError

type PeriodicScheduler

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

func NewPeriodicScheduler

func NewPeriodicScheduler(jobs *JobServer, jobType string, period time.Duration, enabledFunc func(cfg *model.Config) bool) *PeriodicScheduler

func (*PeriodicScheduler) Enabled

func (scheduler *PeriodicScheduler) Enabled(cfg *model.Config) bool

func (*PeriodicScheduler) NextScheduleTime

func (scheduler *PeriodicScheduler) NextScheduleTime(_ *model.Config, _ time.Time, _ bool, _ *model.Job) *time.Time

func (*PeriodicScheduler) ScheduleJob

func (scheduler *PeriodicScheduler) ScheduleJob(_ *model.Config, _ bool, _ *model.Job) (*model.Job, *model.AppError)

type Schedulers

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

func (*Schedulers) AddScheduler

func (schedulers *Schedulers) AddScheduler(name string, scheduler model.Scheduler)

func (*Schedulers) Start

func (schedulers *Schedulers) Start()

Start starts the schedulers. This call is not safe for concurrent use. Synchronization should be implemented by the caller.

func (*Schedulers) Stop

func (schedulers *Schedulers) Stop()

Stop stops the schedulers. This call is not safe for concurrent use. Synchronization should be implemented by the caller.

type SimpleWorker

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

func NewSimpleWorker

func NewSimpleWorker(name string, jobServer *JobServer, execute func(job *model.Job) error, isEnabled func(cfg *model.Config) bool) *SimpleWorker

func (*SimpleWorker) DoJob

func (worker *SimpleWorker) DoJob(job *model.Job)

func (*SimpleWorker) IsEnabled

func (worker *SimpleWorker) IsEnabled(cfg *model.Config) bool

func (*SimpleWorker) JobChannel

func (worker *SimpleWorker) JobChannel() chan<- model.Job

func (*SimpleWorker) Run

func (worker *SimpleWorker) Run()

func (*SimpleWorker) Stop

func (worker *SimpleWorker) Stop()

type Watcher

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

func (*Watcher) PollAndNotify

func (watcher *Watcher) PollAndNotify()

func (*Watcher) Start

func (watcher *Watcher) Start()

func (*Watcher) Stop

func (watcher *Watcher) Stop()

type Workers

type Workers struct {
	ConfigService configservice.ConfigService
	Watcher       *Watcher
	// contains filtered or unexported fields
}

func NewWorkers

func NewWorkers(configService configservice.ConfigService) *Workers

func (*Workers) AddWorker

func (workers *Workers) AddWorker(name string, worker model.Worker)

func (*Workers) Get

func (workers *Workers) Get(name string) model.Worker

func (*Workers) Start

func (workers *Workers) Start()

Start starts the workers. This call is not safe for concurrent use. Synchronization should be implemented by the caller.

func (*Workers) Stop

func (workers *Workers) Stop()

Stop stops the workers. This call is not safe for concurrent use. Synchronization should be implemented by the caller.

Jump to

Keyboard shortcuts

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