scheduler

package
v3.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultRequirements

func DefaultRequirements() *jqs.Requirements

DefaultRequirements returns a minimal set of requirments, which is what NewJob() will use by default.

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, queue 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. If queue is not blank, that queue will be used during NewJob().

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, repGroup, reqGroup, depGroup, dep string, req *jqs.Requirements) *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 the given 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.

If req is supplied, sets the job override to 1. Otherwise, req will default to a minimal set of requirments, and override will be 0. If this Scheduler had been made with a queue override, the requirements will be altered to add that queue.

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