job

package
v0.0.0-...-ac5d820 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package job provides the Job type.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrJobStarted    = errors.New("Job has been started already")
	ErrJobNotStarted = errors.New("Job has not been started")
	ErrInvalidOption = errors.New("Invalid Option")
)

Various predefine error values:

ErrJobStarted indicates that a Job could not be started because it had started already.

ErrJobNotStarted indicates that an operation failed because the Job has not been started yet.

ErrInvalidOption indicates that the Options used for the Job contain an invalid value.

Functions

This section is empty.

Types

type Error

type Error struct {
	Message  string
	Previous error
}

Error is an error type to represent errors related to the lifecycle of a Job.

func (*Error) Error

func (je *Error) Error() string

func (*Error) Unwrap

func (je *Error) Unwrap() error

type Job

type Job struct {
	Options
	ID            int64
	TimeSubmitted time.Time
	TimeStarted   time.Time
	TimeEnded     time.Time
	ExitCode      int
	Cmd           []string
	SpoolOut      string
	SpoolErr      string
	PID           int64
	// contains filtered or unexported fields
}

Job is a batch job, submitted for execution. ID is an integer value that is used to uniquely identify Job instances

Options is of type Options, see there for further reference.

TimeSubmitted is the time the Job was submitted to the queue. To be filled in by the Job queue or scheduler.

TimeStarted and TimeEnded are the times at which the Job was started and ended, to be filled in by the scheduler or monitor.

ExitCode is the exit code given by the operating system.

Cmd is the array of arguments, the first element is the command itself, followed by parameters/arguments.

SpoolOut and SpoolErr are the names of the files where the output of the Job is stored, again to be filled in by the scheduler.

proc (private) is a handle to process while it is running.

func New

func New(options Options, cmd ...string) (*Job, error)

New creates a new Job instance with the given options and command line.

Currently, the error value returned is always nil, but in the future, this might change.

func (*Job) CmdString

func (j *Job) CmdString() string

CmdString returns the Job's command line as a single string.

func (*Job) ProcState

func (j *Job) ProcState() *os.ProcessState

Return the Jobs ProcessState

func (*Job) Start

func (j *Job) Start(outpath, errpath string) error

Start attempts to prepare everything needed for the Job's execution and then start it.

func (*Job) Status

func (j *Job) Status() status.Status

func (*Job) Wait

func (j *Job) Wait() error

Wait waits for a started Job to finish and does the post-processing.

type Options

type Options struct {
	MaxDuration time.Duration
	Directory   string
	Compress    string
	Nice        int
}

Options for the Job

Directories

Path Synopsis
Package status provides symbolic constants to describe the life cycle of a Job.
Package status provides symbolic constants to describe the life cycle of a Job.

Jump to

Keyboard shortcuts

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