jobs

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job struct {
	//timers that get waited
	RegularTimer time.Duration `json:"regularTimer"`
	RetryTimer   time.Duration `json:"retryTimer"`
	//Retry counter/limit
	CurrentRetry     int `json:"CurrentRetry"`
	MaxFailedRetries int `json:"maxFailedRetries"`
	//statemachine status
	Status JobStatus `json:"status"`
	//the progress of the running restic command. not working.
	Progress float64 `json:"progress"`
	//times set when the wait is started
	WaitStart time.Duration `json:"WaitStart"`
	WaitEnd   time.Duration `json:"WaitEnd"`

	//generic data from the config files
	JobNameToTrigger string `json:"NextJob"`
	JobName          string `json:"JobName"`
	Username         string `json:"Username"`
	Service          string `json:"Service"`

	ResticPath      string   `json:"ResticPath"`
	ResticArguments []string `json:"ResticArguments"`
	// contains filtered or unexported fields
}

Job represents one job that will be run in a Queue

func FindJobs

func FindJobs(dirPath string) ([]*Job, error)

FindJobs loads all jobs from the path

func LoadJobFromFile

func LoadJobFromFile(file *os.File) (*Job, error)

LoadJobFromFile loads job from a file

func (*Job) SendTrigger

func (job *Job) SendTrigger(trigType TriggerType)

SendTrigger makes the job run immediatly (if waiting or immediatly again if working right now)

func (*Job) SendTriggerWithDelay

func (job *Job) SendTriggerWithDelay(dur time.Duration)

SendTriggerWithDelay makes the job run after "dur" nanoseconds

func (*Job) Stop

func (job *Job) Stop()

Stop stops a job it will exit after if has finished if currently running (this may take a while!) or exit immediatly if waiting

type JobQueue

type JobQueue struct {
	Jobs      []*Job `json:"Jobs"`
	Wg        *sync.WaitGroup
	Directory string
}

JobQueue managing the jobs

func NewJobQueue

func NewJobQueue(path string) (*JobQueue, error)

NewJobQueue creates a new JobQueue for the given directory

func (*JobQueue) AddJobs

func (queue *JobQueue) AddJobs(jobs ...*Job)

AddJobs adds the jobs to its list and starts them

func (*JobQueue) FindJob

func (queue *JobQueue) FindJob(name string) (*Job, int)

func (*JobQueue) JobExists

func (queue *JobQueue) JobExists(name string) bool

JobExists Check if this job is in the queue

func (*JobQueue) ReloadJob

func (queue *JobQueue) ReloadJob(name string) error

ReloadJob reloads the file (with all changes made to it) and replaces the old job with the new one. the old job is stopped (and waited for until stopped) before the new job is started

func (*JobQueue) RemoveJob

func (queue *JobQueue) RemoveJob(name string) error

RemoveJob stops the job and then removes it from the queue

func (*JobQueue) RestartJob

func (queue *JobQueue) RestartJob(name string) error

RestartJob restarts the job with this name if it is present and in the "stopped" State

func (*JobQueue) StartQueue

func (queue *JobQueue) StartQueue()

StartQueue starts all the jobs in the directory

func (*JobQueue) StopAllJobs

func (queue *JobQueue) StopAllJobs()

StopAllJobs can take a long time depending on the jobs

func (*JobQueue) StopJob

func (queue *JobQueue) StopJob(name string) error

StopJob stops the job with this name

func (*JobQueue) TriggerJob

func (queue *JobQueue) TriggerJob(name string) error

TriggerJob triggers the job with the extern trigger so it doesnt trigger itself afterwards

func (*JobQueue) WaitForAllJobs

func (queue *JobQueue) WaitForAllJobs()

WaitForAllJobs does what it says it does

type JobReturn

type JobReturn int

JobReturn status returns from jobs

type JobStatus

type JobStatus string

JobStatus stati the jobs can be in

type JobStore

type JobStore interface {
	FindJob(name string) (*Job, int)
}

JobStore can have your job

type TriggerType

type TriggerType int

TriggerType extern triggers only followup jobs but does not retrigger himself

Jump to

Keyboard shortcuts

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