scheduler

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UniqueString

func UniqueString() string

UniqueString returns a unique string that could be useful for supplying as depGroup values to NewJob() etc. The length is always 20 characters.

Types

type Error

type Error string

func (Error) Error

func (e Error) Error() string

type Scheduler

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

Scheduler can be used to schedule commands to be executed by adding them to wr's queue.

func New

func New(deployment, cwd string, timeout time.Duration, logger log15.Logger, sudo bool) (*Scheduler, error)

New returns a Scheduler that is connected to wr manager using the given deployment, timeout and logger. If sudo is true, NewJob() will prefix 'sudo' to commands. Added jobs will have the given cwd, which matters. If cwd is blank, the current working dir is used.

func (*Scheduler) Disconnect

func (s *Scheduler) Disconnect() error

Disconnect disconnects from the manager. You should defer this after New().

func (*Scheduler) Executable

func (s *Scheduler) Executable() string

Executable is a convenience function that returns the same as os.Executable(), but without the error.

func (*Scheduler) NewJob

func (s *Scheduler) NewJob(cmd, rep, req, depGroup, dep string) *jobqueue.Job

NewJob is a convenience function for creating Jobs. It sets the job's Cwd to the current working directory, sets CwdMatters to true, applies a minimal Requirements, and sets Retries to 3.

If this Scheduler had been made with sudo: true, cmd will be prefixed with 'sudo '.

THe supplied depGroup and dep can be blank to not set DepGroups and Dependencies.

func (*Scheduler) SubmitJobs

func (s *Scheduler) SubmitJobs(jobs []*jobqueue.Job) error

SubmitJobs adds the given jobs to wr's queue, passing through current environment variables.

Previously added identical jobs that have since been archived will get added again.

If any duplicate jobs were added, an error will be returned.

Jump to

Keyboard shortcuts

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