Documentation
¶
Overview ¶
Package taskctl contains custom implementations and extensions for the github.com/taskctl/taskctl packages
Index ¶
- Constants
- type FileOutputStore
- type LineWriter
- type Opts
- type OutputStore
- type PgidExecutor
- type Runner
- type Scheduler
- type TaskRunner
- func (r *TaskRunner) Cancel()
- func (r *TaskRunner) Finish()
- func (r *TaskRunner) Run(t *task.Task) error
- func (r *TaskRunner) SetContexts(contexts map[string]*runner.ExecutionContext) *TaskRunner
- func (r *TaskRunner) SetOnTaskChange(f func(t *task.Task))
- func (r *TaskRunner) SetVariables(vars variables.Container) *TaskRunner
- func (r *TaskRunner) WithVariable(key, value string) *TaskRunner
Examples ¶
Constants ¶
const JobIDVariableName = "__jobID"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileOutputStore ¶
type FileOutputStore struct {
// contains filtered or unexported fields
}
func NewOutputStore ¶
func NewOutputStore(path string) (*FileOutputStore, error)
func (*FileOutputStore) Reader ¶
func (s *FileOutputStore) Reader(jobID string, taskName string, outputName string) (io.ReadCloser, error)
func (*FileOutputStore) Remove ¶ added in v0.4.0
func (s *FileOutputStore) Remove(jobID string) error
func (*FileOutputStore) Writer ¶
func (s *FileOutputStore) Writer(jobID string, taskName string, outputName string) (io.WriteCloser, error)
type LineWriter ¶
type LineWriter struct {
// contains filtered or unexported fields
}
LineWriter splits written data into lines This is not used yet but prepared for streaming output later.
func (*LineWriter) Finish ¶
func (l *LineWriter) Finish()
func (*LineWriter) Lines ¶
func (l *LineWriter) Lines() [][]byte
type Opts ¶
type Opts func(*TaskRunner)
Opts is a task runner configuration function.
func WithContexts ¶
func WithContexts(contexts map[string]*runner.ExecutionContext) Opts
WithContexts adds provided contexts to task runner
func WithKillTimeout ¶ added in v0.8.1
WithKillTimeout sets the kill timeout for execution of commands
func WithVariables ¶
WithVariables adds provided variables to task runner
type OutputStore ¶
type PgidExecutor ¶ added in v0.8.1
type PgidExecutor struct {
// contains filtered or unexported fields
}
PgidExecutor is an executor that starts commands in a new process group (if supported by OS)
It is based on executor.DefaultExecutor but uses an exec handler that sets setpgid to start child processes in a new process group (with negative pid). It is used to prevent signals from propagating to children and to kill all descendant processes e.g. when forked by a shell process.
func NewPgidExecutor ¶ added in v0.8.1
func NewPgidExecutor(stdin io.Reader, stdout, stderr io.Writer, killTimeout time.Duration) (*PgidExecutor, error)
NewPgidExecutor creates new pgid executor
type Runner ¶
Runner extends runner.Runner (from taskctl) to implement additional features: - storage of outputs - callback on finished task (so we can f.e. schedule the next task when one is on the wait-queue) The file https://github.com/taskctl/taskctl/blob/master/pkg/runner/runner.go is the original basis of this file.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler executes ExecutionGraph
func NewScheduler ¶
NewScheduler create new Scheduler instance
func (*Scheduler) OnStageChange ¶
func (*Scheduler) Schedule ¶
func (s *Scheduler) Schedule(g *scheduler.ExecutionGraph) error
Schedule starts execution of the given ExecutionGraph
Modified to notify on stage changes
Example ¶
format := task.FromCommands("go fmt ./...") build := task.FromCommands("go build ./..") r, _ := runner.NewTaskRunner() s := NewScheduler(r) graph, err := scheduler.NewExecutionGraph( &scheduler.Stage{Name: "format", Task: format}, &scheduler.Stage{Name: "build", Task: build, DependsOn: []string{"format"}}, ) if err != nil { return } err = s.Schedule(graph) if err != nil { fmt.Println(err) }
Output:
type TaskRunner ¶
type TaskRunner struct { Stdin io.Reader Stdout, Stderr io.Writer OutputFormat string // contains filtered or unexported fields }
TaskRunner run tasks
func NewTaskRunner ¶
func NewTaskRunner(outputStore OutputStore, opts ...Opts) (*TaskRunner, error)
NewTaskRunner creates new TaskRunner instance
func (*TaskRunner) Run ¶
func (r *TaskRunner) Run(t *task.Task) error
Run run provided task -> highly modified from taskctl/runner/runner.go TaskRunner first compiles task into linked list of Jobs, then passes those jobs to Executor
Example ¶
t := task.FromCommands("go fmt ./...", "go build ./..") r, err := NewTaskRunner(nil) if err != nil { return } err = r.Run(t) if err != nil { fmt.Println(err, t.ExitCode, t.ErrorMessage()) } fmt.Println(t.Output())
Output:
func (*TaskRunner) SetContexts ¶
func (r *TaskRunner) SetContexts(contexts map[string]*runner.ExecutionContext) *TaskRunner
SetContexts sets task runner's contexts
func (*TaskRunner) SetOnTaskChange ¶
func (r *TaskRunner) SetOnTaskChange(f func(t *task.Task))
SetOnTaskChange is synchronous; so you can read the task in any way inside the callback because there is no concurrent access of the task
func (*TaskRunner) SetVariables ¶
func (r *TaskRunner) SetVariables(vars variables.Container) *TaskRunner
SetVariables sets task runner's variables
func (*TaskRunner) WithVariable ¶
func (r *TaskRunner) WithVariable(key, value string) *TaskRunner
WithVariable adds variable to task runner's variables list. It creates new instance of variables container.