Documentation
¶
Overview ¶
Copyright © 2023 Jonathan Gotti <jgotti at jgotti dot org> SPDX-FileType: SOURCE SPDX-License-Identifier: MIT SPDX-FileCopyrightText: 2023 Jonathan Gotti <jgotti@jgotti.org>
Index ¶
- Constants
- func SetMaxConcurrentJobs(n int)
- func SetTemplateString(templateString string)
- type JobExecutor
- func (e *JobExecutor) AddJobCmds(cmds ...*exec.Cmd) *JobExecutor
- func (e *JobExecutor) AddJobFns(fns ...runnableFn) *JobExecutor
- func (e *JobExecutor) AddNamedJobCmd(name string, cmd *exec.Cmd) *JobExecutor
- func (e *JobExecutor) AddNamedJobFn(name string, fn runnableFn) *JobExecutor
- func (e *JobExecutor) Execute() JobsError
- func (e *JobExecutor) Len() int
- func (e *JobExecutor) OnJobDone(fn jobEventHandler) *JobExecutor
- func (e *JobExecutor) OnJobStart(fn jobEventHandler) *JobExecutor
- func (e *JobExecutor) OnJobsDone(fn jobsEventHandler) *JobExecutor
- func (e *JobExecutor) OnJobsStart(fn jobsEventHandler) *JobExecutor
- func (e *JobExecutor) WithFifoOutput() *JobExecutor
- func (e *JobExecutor) WithOrderedOutput() *JobExecutor
- func (e *JobExecutor) WithProgressOutput() *JobExecutor
- func (e *JobExecutor) WithStartOutput() *JobExecutor
- func (e *JobExecutor) WithStartSummary() *JobExecutor
- type JobList
- type JobsError
Constants ¶
const ( JobStatePending = 0 JobStateRunning = 1 JobStateDone = 2 JobStateSucceed = 4 JobStateFailed = 8 )
Variables ¶
This section is empty.
Functions ¶
func SetMaxConcurrentJobs ¶
func SetMaxConcurrentJobs(n int)
set the default number of concurrent jobs to run default to GOMAXPROCS
func SetTemplateString ¶
func SetTemplateString(templateString string)
Template for all outputs related to jobs It must define the following templates:
- startSummary: which will receive a JobList
- jobStatus: which will receive a single job
- progressReport: which will receive a jobList
- doneReport: which will receive a jobList
Types ¶
type JobExecutor ¶
type JobExecutor struct {
// contains filtered or unexported fields
}
func (*JobExecutor) AddJobCmds ¶
func (e *JobExecutor) AddJobCmds(cmds ...*exec.Cmd) *JobExecutor
Add multiple job commands to run
func (*JobExecutor) AddJobFns ¶
func (e *JobExecutor) AddJobFns(fns ...runnableFn) *JobExecutor
Add one or more job function to run (func() (string, error))
func (*JobExecutor) AddNamedJobCmd ¶ added in v1.0.0
func (e *JobExecutor) AddNamedJobCmd(name string, cmd *exec.Cmd) *JobExecutor
Add a job command and set its output display name
func (*JobExecutor) AddNamedJobFn ¶ added in v1.0.0
func (e *JobExecutor) AddNamedJobFn(name string, fn runnableFn) *JobExecutor
Add a job function and set its output display name
func (*JobExecutor) Execute ¶
func (e *JobExecutor) Execute() JobsError
Effectively execute jobs and return collected errors as JobsError
func (*JobExecutor) Len ¶
func (e *JobExecutor) Len() int
Return the total number of jobs added to the jobExecutor
func (*JobExecutor) OnJobDone ¶
func (e *JobExecutor) OnJobDone(fn jobEventHandler) *JobExecutor
Add a handler which will be called after a job is terminated
func (*JobExecutor) OnJobStart ¶
func (e *JobExecutor) OnJobStart(fn jobEventHandler) *JobExecutor
Add a handler which will be called before a job is started
func (*JobExecutor) OnJobsDone ¶
func (e *JobExecutor) OnJobsDone(fn jobsEventHandler) *JobExecutor
Add a handler which will be called after all jobs are terminated
func (*JobExecutor) OnJobsStart ¶
func (e *JobExecutor) OnJobsStart(fn jobsEventHandler) *JobExecutor
Add a handler which will be called before any jobs is started
func (*JobExecutor) WithFifoOutput ¶
func (e *JobExecutor) WithFifoOutput() *JobExecutor
Display full jobStatus as they arrive
func (*JobExecutor) WithOrderedOutput ¶
func (e *JobExecutor) WithOrderedOutput() *JobExecutor
Display doneReport when all jobs are Done
func (*JobExecutor) WithProgressOutput ¶
func (e *JobExecutor) WithProgressOutput() *JobExecutor
Display a job status report updated each time a job start or end be carefull when dealing with other handler that generate output as it will potentially break progress output
func (*JobExecutor) WithStartOutput ¶
func (e *JobExecutor) WithStartOutput() *JobExecutor
Output a line to say a job is starting
func (*JobExecutor) WithStartSummary ¶
func (e *JobExecutor) WithStartSummary() *JobExecutor
Output a summary of jobs that will be run