Documentation ¶
Index ¶
- func DefaultRequirements() *jqs.Requirements
- func UniqueString() string
- type Error
- type Scheduler
- func (s *Scheduler) DisableSudo()
- func (s *Scheduler) Disconnect() error
- func (s *Scheduler) EnableSudo()
- func (s *Scheduler) Executable() string
- func (s *Scheduler) NewJob(cmd, repGroup, reqGroup, depGroup, dep string, req *jqs.Requirements) *jobqueue.Job
- func (s *Scheduler) SubmitJobs(jobs []*jobqueue.Job) error
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 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, queuesAvoid string, timeout time.Duration, logger log15.Logger) (*Scheduler, error)
New returns a Scheduler that is connected to wr manager using the given deployment, timeout and logger. 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(). If queuesAvoid is not blank, queues including a substring from the list will be avoided during NewJob().
func (*Scheduler) DisableSudo ¶
func (s *Scheduler) DisableSudo()
DisableSudo is used to disable sudo if it was enabled with EnableSudo.
func (*Scheduler) Disconnect ¶
Disconnect disconnects from the manager. You should defer this after New().
func (*Scheduler) EnableSudo ¶
func (s *Scheduler) EnableSudo()
EnableSudo causes NewJob() to prefix 'sudo' to commands.
func (*Scheduler) Executable ¶
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 ¶
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.