schedule

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: GPL-3.0 Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorServiceNotFound   = errors.New("service not found")
	ErrorServiceNotRunning = errors.New("service is not running")
)

Generic errors

View Source
var ErrorJobCanBeRemovedOnly = errors.New("job can be removed only")
View Source
var (
	// ScheduledSections are the command that can be scheduled (backup, retention, check, prune)
	ScheduledSections = []string{
		constants.CommandBackup,
		constants.SectionConfigurationRetention,
		constants.CommandCheck,
		constants.CommandForget,
		constants.CommandPrune,
	}
)

Functions

This section is empty.

Types

type Config

type Config interface {
	Title() string
	SubTitle() string
	JobDescription() string
	TimerDescription() string
	Schedules() []string
	Permission() string
	WorkingDirectory() string
	Command() string
	Arguments() []string
	Environment() map[string]string
	Priority() string
	Logfile() string
	Configfile() string
	GetFlag(string) (string, bool)
}

Config contains all the information needed to schedule a Job

func NewRemoveOnlyConfig added in v0.12.0

func NewRemoveOnlyConfig(profileName, commandName string) Config

NewRemoveOnlyConfig creates a job config that may be used to call Job.Remove() on a scheduled job

type CrondSchedule added in v0.11.0

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

CrondSchedule is a Scheduler using crond

func (*CrondSchedule) Close added in v0.11.0

func (s *CrondSchedule) Close()

Close does nothing when using crond

func (*CrondSchedule) DisplayStatus added in v0.11.0

func (s *CrondSchedule) DisplayStatus()

DisplayStatus does nothing in crond

func (*CrondSchedule) Init added in v0.11.0

func (s *CrondSchedule) Init() error

Init verifies crond is available on this system

func (*CrondSchedule) NewJob added in v0.11.0

func (s *CrondSchedule) NewJob(config Config) SchedulerJob

NewJob instantiates a Job object (of SchedulerJob interface) to schedule jobs

type Job

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

Job scheduler

func (*Job) Accessible added in v0.12.0

func (j *Job) Accessible() bool

Accessible checks if the current user is permitted to access the job

func (*Job) Create

func (j *Job) Create() error

Create a new job

func (*Job) Remove

func (j *Job) Remove() error

Remove a job

func (*Job) RemoveOnly added in v0.12.0

func (j *Job) RemoveOnly() bool

RemoveOnly returns true if this job can be removed only

func (*Job) Status

func (j *Job) Status() error

Status of a job

type Permission

type Permission int

Permission is either system or user

const (
	PermissionUser Permission = iota
	PermissionSystem
)

Permission

func (Permission) String

func (p Permission) String() string

type RemoveOnlyConfig added in v0.12.0

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

RemoveOnlyConfig implements Config for jobs that are Job.RemoveOnly()

func (*RemoveOnlyConfig) Arguments added in v0.12.0

func (r *RemoveOnlyConfig) Arguments() []string

func (*RemoveOnlyConfig) Command added in v0.12.0

func (r *RemoveOnlyConfig) Command() string

func (*RemoveOnlyConfig) Configfile added in v0.12.0

func (r *RemoveOnlyConfig) Configfile() string

func (*RemoveOnlyConfig) Environment added in v0.12.0

func (r *RemoveOnlyConfig) Environment() map[string]string

func (*RemoveOnlyConfig) GetFlag added in v0.12.0

func (r *RemoveOnlyConfig) GetFlag(string) (string, bool)

func (*RemoveOnlyConfig) JobDescription added in v0.12.0

func (r *RemoveOnlyConfig) JobDescription() string

func (*RemoveOnlyConfig) Logfile added in v0.12.0

func (r *RemoveOnlyConfig) Logfile() string

func (*RemoveOnlyConfig) Permission added in v0.12.0

func (r *RemoveOnlyConfig) Permission() string

func (*RemoveOnlyConfig) Priority added in v0.12.0

func (r *RemoveOnlyConfig) Priority() string

func (*RemoveOnlyConfig) Schedules added in v0.12.0

func (r *RemoveOnlyConfig) Schedules() []string

func (*RemoveOnlyConfig) SubTitle added in v0.12.0

func (r *RemoveOnlyConfig) SubTitle() string

func (*RemoveOnlyConfig) TimerDescription added in v0.12.0

func (r *RemoveOnlyConfig) TimerDescription() string

func (*RemoveOnlyConfig) Title added in v0.12.0

func (r *RemoveOnlyConfig) Title() string

func (*RemoveOnlyConfig) WorkingDirectory added in v0.12.0

func (r *RemoveOnlyConfig) WorkingDirectory() string

type Scheduler added in v0.11.0

type Scheduler interface {
	Init() error
	Close()
	NewJob(Config) SchedulerJob
	DisplayStatus()
}

Scheduler interface

func NewScheduler added in v0.11.0

func NewScheduler(scheduler, profileName string) Scheduler

NewScheduler creates a Scheduler interface, which is either a CrondSchedule or a SystemdSchedule object

type SchedulerJob added in v0.11.0

type SchedulerJob interface {
	Accessible() bool
	Create() error
	Remove() error
	RemoveOnly() bool
	Status() error
}

SchedulerJob interface

type SystemdSchedule added in v0.11.0

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

SystemdSchedule is a Scheduler using systemd

func (*SystemdSchedule) Close added in v0.11.0

func (s *SystemdSchedule) Close()

Close does nothing when using systemd

func (*SystemdSchedule) DisplayStatus added in v0.11.0

func (s *SystemdSchedule) DisplayStatus()

DisplayStatus display timers in systemd

func (*SystemdSchedule) Init added in v0.11.0

func (s *SystemdSchedule) Init() error

Init verifies systemd is available on this system

func (*SystemdSchedule) NewJob added in v0.11.0

func (s *SystemdSchedule) NewJob(config Config) SchedulerJob

NewJob instantiates a Job object (of SchedulerJob interface) to schedule jobs

Jump to

Keyboard shortcuts

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