Documentation
¶
Index ¶
- Constants
- Variables
- func SafeBytesToStr(output []byte) (outputStr string, isBase64 bool)
- func SerializeRunRec(rec RunRec, data ResultSinkDataParam) []byte
- func ShouldLoadJobfile(f *os.File, usr *user.User) (bool, error)
- type BackoffErrorHandler
- type ContinueErrorHandler
- type ErrorHandler
- type FileJobOutputHandler
- type FilesystemResultSink
- type FullTimeSpec
- type Job
- type JobFile
- type JobFileRaw
- type JobFileV1V2Raw
- type JobFileV3Raw
- type JobOutputHandler
- type JobRaw
- type JobStatus
- type JobV1V2Raw
- type JobV3Raw
- type NopJobOutputHandler
- type OneValTimeSpec
- type ProgramResultSink
- type RandomTimeSpec
- type ResultSink
- type ResultSinkDataParam
- type ResultSinkRaw
- type RunLog
- type RunLogEntry
- type RunLogRaw
- type RunRec
- type SemVer
- type SetTimeSpec
- type SocketResultSink
- type StdoutResultSink
- type StopErrorHandler
- type SystemEmailResultSink
- type TimeSpec
- type UserPrefs
- type UserPrefsV1V2Raw
- type UserPrefsV3Raw
- type WildcardTimeSpec
Constants ¶
const ( ErrorHandlerStopName = "Stop" ErrorHandlerBackoffName = "Backoff" ErrorHandlerContinueName = "Continue" MaxBackoffWait = 8 )
const ( PrefsSectName = "prefs" JobsSectName = "jobs" )
const RunRecOutputMaxLen = 1 << 20
const (
TimeWildcard = "*"
)
Variables ¶
var GlobalRunRecServerRegistry runRecServerRegistry
var JobStatuses = [...]JobStatus{ JobGood, JobFailed, JobBackoff, }
Functions ¶
func SafeBytesToStr ¶ added in v1.4.0
func SerializeRunRec ¶ added in v1.4.0
func SerializeRunRec(rec RunRec, data ResultSinkDataParam) []byte
Types ¶
type BackoffErrorHandler ¶ added in v1.4.0
type BackoffErrorHandler struct{}
func (BackoffErrorHandler) Handle ¶ added in v1.4.0
func (self BackoffErrorHandler) Handle(job *Job)
func (BackoffErrorHandler) String ¶ added in v1.4.0
func (self BackoffErrorHandler) String() string
type ContinueErrorHandler ¶ added in v1.4.0
type ContinueErrorHandler struct{}
func (ContinueErrorHandler) Handle ¶ added in v1.4.0
func (self ContinueErrorHandler) Handle(job *Job)
func (ContinueErrorHandler) String ¶ added in v1.4.0
func (self ContinueErrorHandler) String() string
type ErrorHandler ¶
func GetErrorHandler ¶ added in v1.4.0
func GetErrorHandler(name string) (ErrorHandler, error)
type FileJobOutputHandler ¶ added in v1.4.0
func (FileJobOutputHandler) String ¶ added in v1.4.0
func (self FileJobOutputHandler) String() string
func (FileJobOutputHandler) WriteOutput ¶ added in v1.4.0
func (self FileJobOutputHandler) WriteOutput(output []byte, jobName string, runTime time.Time)
type FilesystemResultSink ¶ added in v1.4.0
type FilesystemResultSink struct { Path string `yaml:"path"` Data ResultSinkDataParam `yaml:"data"` MaxAgeDays int `yaml:"maxAgeDays"` }
This result sink writes a run's stdout or stderr to disk.
Example: Consider FilesystemResultSink{Path: "/some/dir", DataRaw: ["stdout", "stderr"]}. For a job named "JobOne", this will result in a set of files like this:
- /some/dir/
- JobOne/
- 1521318351.stdout
- 1521318351.stderr
- 1521318411.stdout
- 1521318411.stderr
- 1521318471.stdout
- 1521318471.stderr
func (FilesystemResultSink) CheckParams ¶ added in v1.4.0
func (self FilesystemResultSink) CheckParams() error
func (FilesystemResultSink) Equals ¶ added in v1.4.0
func (self FilesystemResultSink) Equals(other ResultSink) bool
func (FilesystemResultSink) Handle ¶ added in v1.4.0
func (self FilesystemResultSink) Handle(rec RunRec)
func (FilesystemResultSink) String ¶ added in v1.4.0
func (self FilesystemResultSink) String() string
type FullTimeSpec ¶
type FullTimeSpec struct { Sec TimeSpec Min TimeSpec Hour TimeSpec Mday TimeSpec Mon TimeSpec Wday TimeSpec }
func ParseFullTimeSpec ¶
func ParseFullTimeSpec(s string) (*FullTimeSpec, error)
func (*FullTimeSpec) Derandomize ¶ added in v1.3.0
func (self *FullTimeSpec) Derandomize()
func (FullTimeSpec) Satisfied ¶ added in v1.3.1
func (self FullTimeSpec) Satisfied(t time.Time) bool
func (FullTimeSpec) String ¶
func (self FullTimeSpec) String() string
type Job ¶
type Job struct { // params Name string Cmd string FullTimeSpec FullTimeSpec User string ErrorHandler ErrorHandler NotifyOnError []ResultSink NotifyOnFailure []ResultSink NotifyOnSuccess []ResultSink // other dynamic stuff NextRunTime *time.Time Status JobStatus LastRunTime time.Time Paused bool // contains filtered or unexported fields }
type JobFile ¶ added in v1.3.0
type JobFile struct { Prefs UserPrefs Jobs map[string]*Job Raw JobFileRaw }
func (*JobFile) InitResultSinks ¶ added in v1.4.0
func (self *JobFile) InitResultSinks()
type JobFileRaw ¶ added in v1.4.3
type JobFileRaw = JobFileV3Raw
func LoadJobfile ¶ added in v1.3.0
func LoadJobfile(f *os.File) (*JobFileRaw, error)
func NewEmptyRawJobFile ¶ added in v1.4.3
func NewEmptyRawJobFile() *JobFileRaw
type JobFileV1V2Raw ¶ added in v1.4.0
type JobFileV1V2Raw struct { Prefs UserPrefsV1V2Raw Jobs []JobV1V2Raw }
type JobFileV3Raw ¶ added in v1.4.0
type JobFileV3Raw struct { Version SemVer `yaml:"version"` Prefs UserPrefsV3Raw `yaml:"prefs"` Jobs map[string]JobV3Raw `yaml:"jobs"` }
func (*JobFileV3Raw) Activate ¶ added in v1.4.3
func (self *JobFileV3Raw) Activate(usr *user.User) (*JobFile, error)
func (*JobFileV3Raw) Dup ¶ added in v1.4.3
func (self *JobFileV3Raw) Dup() *JobFileV3Raw
type JobOutputHandler ¶ added in v1.4.0
type JobV1V2Raw ¶ added in v1.4.0
type JobV1V2Raw struct { Name string `json:"name" yaml:"name"` Cmd string `json:"cmd" yaml:"cmd"` Time string `json:"time" yaml:"time"` OnError *string `json:"onError" yaml:"onError"` NotifyOnSuccess *bool `json:"notifyOnSuccess" yaml:"notifyOnSuccess"` NotifyOnError *bool `json:"notifyOnError" yaml:"notifyOnError"` NotifyOnFailure *bool `json:"notifyOnFailure" yaml:"notifyOnFailure"` }
type JobV3Raw ¶ added in v1.4.0
type JobV3Raw struct { Cmd string `json:"cmd" yaml:"cmd"` Time string `json:"time" yaml:"time"` OnError *string `json:"onError" yaml:"onError"` NotifyOnSuccess []ResultSinkRaw `json:"notifyOnSuccess" yaml:"notifyOnSuccess"` NotifyOnError []ResultSinkRaw `json:"notifyOnError" yaml:"notifyOnError"` NotifyOnFailure []ResultSinkRaw `json:"notifyOnFailure" yaml:"notifyOnFailure"` }
type NopJobOutputHandler ¶ added in v1.4.0
type NopJobOutputHandler struct{}
func (NopJobOutputHandler) String ¶ added in v1.4.0
func (self NopJobOutputHandler) String() string
func (NopJobOutputHandler) WriteOutput ¶ added in v1.4.0
func (self NopJobOutputHandler) WriteOutput(output []byte, jobName string, runTime time.Time)
type OneValTimeSpec ¶
type OneValTimeSpec struct {
// contains filtered or unexported fields
}
func (OneValTimeSpec) Derandomize ¶ added in v1.4.0
func (self OneValTimeSpec) Derandomize()
func (OneValTimeSpec) IsWildcard ¶ added in v1.3.1
func (self OneValTimeSpec) IsWildcard() bool
func (OneValTimeSpec) Satisfied ¶
func (self OneValTimeSpec) Satisfied(v int) bool
func (OneValTimeSpec) String ¶
func (self OneValTimeSpec) String() string
type ProgramResultSink ¶ added in v1.4.0
type ProgramResultSink struct { Path string `yaml:"path"` RunRecFormatVersion SemVer `yaml:"runRecFormatVersion"` }
func (ProgramResultSink) CheckParams ¶ added in v1.4.0
func (self ProgramResultSink) CheckParams() error
func (ProgramResultSink) Equals ¶ added in v1.4.0
func (self ProgramResultSink) Equals(other ResultSink) bool
func (ProgramResultSink) Handle ¶ added in v1.4.0
func (self ProgramResultSink) Handle(rec RunRec)
func (ProgramResultSink) String ¶ added in v1.4.0
func (self ProgramResultSink) String() string
type RandomTimeSpec ¶ added in v1.3.0
type RandomTimeSpec struct {
// contains filtered or unexported fields
}
A time spec that chooses (pseudo-)randomly from a set of values. Each value in that set has an (approximately) equal chance of getting picked.
func (*RandomTimeSpec) Derandomize ¶ added in v1.3.0
func (self *RandomTimeSpec) Derandomize()
Pick a random value, and remember it so that it can be used by the method Satisfied.
The method Satisfied will panic unless this method has been called.
If this method has already been called, calling it again has no effect.
func (RandomTimeSpec) IsWildcard ¶ added in v1.3.1
func (self RandomTimeSpec) IsWildcard() bool
func (RandomTimeSpec) PickedValue ¶ added in v1.3.0
func (self RandomTimeSpec) PickedValue() *int
Get the picked value. If Derandomize has never been called, returns nil.
func (RandomTimeSpec) Satisfied ¶ added in v1.3.0
func (self RandomTimeSpec) Satisfied(val int) bool
Get whether the time spec is satisfied by val.
If Derandomize has never been called, this method will panic.
func (RandomTimeSpec) String ¶ added in v1.3.0
func (self RandomTimeSpec) String() string
type ResultSink ¶ added in v1.4.0
type ResultSink interface { /* Do something with the given run record. */ Handle(runRec RunRec) /* Check for problems with the params. This is called just after deserialization from a jobfile. */ CheckParams() error Equals(other ResultSink) bool fmt.Stringer }
A result sink is an object that does something with the results of a job run.
func MakeResultSinkFromConfig ¶ added in v1.4.0
func MakeResultSinkFromConfig(config ResultSinkRaw) (ResultSink, error)
type ResultSinkDataParam ¶ added in v1.4.0
type ResultSinkDataParam uint
const ( RESULT_SINK_DATA_STDOUT ResultSinkDataParam = 1 << iota RESULT_SINK_DATA_STDERR )
func (ResultSinkDataParam) Contains ¶ added in v1.4.0
func (self ResultSinkDataParam) Contains(value ResultSinkDataParam) bool
func (*ResultSinkDataParam) UnmarshalYAML ¶ added in v1.4.0
func (self *ResultSinkDataParam) UnmarshalYAML(unmarshal func(interface{}) error) error
type ResultSinkRaw ¶ added in v1.4.0
type ResultSinkRaw map[string]interface{}
type RunLog ¶ added in v1.3.0
type RunLog interface { /* There are two ways to use this method. "GetFromTime(t)": Get all entries for runs that started no later than t. "GetFromTime(t1, t2)": Get all entries that started no later than t1 but later than t2. The entries are returned in order of start time, descending. */ GetFromTime(maxTime time.Time, minTime ...time.Time) ([]*RunLogEntry, error) /* There are two ways to use this method. "GetFromIndex(i)": Get all entries with index >= i. "GetFromIndex(i, j)": Get all entries with index >= i but < j. */ GetFromIndex(minIdx int, maxIdx ...int) ([]*RunLogEntry, error) /* Get all entries. */ GetAll() ([]*RunLogEntry, error) Len() int Put(entry RunLogEntry) error }
This is a database of job runs. It may be backed by a file, or it may not: this depends on the user's preferences specified in the jobfile.
func NewFileRunLog ¶ added in v1.3.0
func NewMemOnlyRunLog ¶ added in v1.3.0
type RunLogEntry ¶ added in v1.3.0
type RunLogRaw ¶ added in v1.4.0
type RunRec ¶
type SemVer ¶ added in v1.4.0
func (SemVer) MarshalJSON ¶ added in v1.4.0
func (SemVer) MarshalYAML ¶ added in v1.4.0
func (*SemVer) UnmarshalYAML ¶ added in v1.4.0
type SetTimeSpec ¶
type SetTimeSpec struct {
// contains filtered or unexported fields
}
func (SetTimeSpec) Derandomize ¶ added in v1.4.0
func (self SetTimeSpec) Derandomize()
func (SetTimeSpec) IsWildcard ¶ added in v1.3.1
func (self SetTimeSpec) IsWildcard() bool
func (SetTimeSpec) Satisfied ¶
func (self SetTimeSpec) Satisfied(v int) bool
func (SetTimeSpec) String ¶
func (self SetTimeSpec) String() string
type SocketResultSink ¶ added in v1.4.0
type SocketResultSink struct { Proto string `yaml:"proto"` Address string `yaml:"address"` Data ResultSinkDataParam `yaml:"data"` }
func (SocketResultSink) CheckParams ¶ added in v1.4.0
func (self SocketResultSink) CheckParams() error
func (SocketResultSink) Equals ¶ added in v1.4.0
func (self SocketResultSink) Equals(other ResultSink) bool
func (SocketResultSink) Handle ¶ added in v1.4.0
func (self SocketResultSink) Handle(runRec RunRec)
func (SocketResultSink) String ¶ added in v1.4.0
func (self SocketResultSink) String() string
type StdoutResultSink ¶ added in v1.4.0
type StdoutResultSink struct {
Data ResultSinkDataParam `yaml:"data"`
}
This result sink sends run results to jobberrunner's stdout.
func (StdoutResultSink) CheckParams ¶ added in v1.4.0
func (self StdoutResultSink) CheckParams() error
func (StdoutResultSink) Equals ¶ added in v1.4.0
func (self StdoutResultSink) Equals(other ResultSink) bool
func (StdoutResultSink) Handle ¶ added in v1.4.0
func (self StdoutResultSink) Handle(rec RunRec)
func (StdoutResultSink) String ¶ added in v1.4.0
func (self StdoutResultSink) String() string
type StopErrorHandler ¶ added in v1.4.0
type StopErrorHandler struct{}
func (StopErrorHandler) Handle ¶ added in v1.4.0
func (self StopErrorHandler) Handle(job *Job)
func (StopErrorHandler) String ¶ added in v1.4.0
func (self StopErrorHandler) String() string
type SystemEmailResultSink ¶ added in v1.4.0
type SystemEmailResultSink struct{}
func (SystemEmailResultSink) CheckParams ¶ added in v1.4.0
func (self SystemEmailResultSink) CheckParams() error
func (SystemEmailResultSink) Equals ¶ added in v1.4.0
func (self SystemEmailResultSink) Equals(other ResultSink) bool
func (SystemEmailResultSink) Handle ¶ added in v1.4.0
func (self SystemEmailResultSink) Handle(rec RunRec)
func (SystemEmailResultSink) String ¶ added in v1.4.0
func (self SystemEmailResultSink) String() string
type UserPrefsV1V2Raw ¶ added in v1.4.0
type UserPrefsV3Raw ¶ added in v1.4.0
type WildcardTimeSpec ¶
type WildcardTimeSpec struct{}
func (WildcardTimeSpec) Derandomize ¶ added in v1.4.0
func (self WildcardTimeSpec) Derandomize()
func (WildcardTimeSpec) IsWildcard ¶ added in v1.3.1
func (self WildcardTimeSpec) IsWildcard() bool
func (WildcardTimeSpec) Satisfied ¶
func (self WildcardTimeSpec) Satisfied(v int) bool
func (WildcardTimeSpec) String ¶
func (self WildcardTimeSpec) String() string
Source Files
¶
- error_handler.go
- file_run_log.go
- job.go
- job_file.go
- job_output_handler.go
- mem_only_run_log.go
- result_sink.go
- result_sink_filesystem.go
- result_sink_program.go
- result_sink_socket.go
- result_sink_stdout.go
- result_sink_system_email.go
- run_log.go
- run_rec_server.go
- safe_bytes_to_str.go
- semver.go
- time_spec.go