worker

package
v0.0.0-...-39e769a Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorJobNotFound = errors.New("job not found")

Functions

This section is empty.

Types

type CancelFunc

type CancelFunc func()

type Command

type Command struct {
	Cmd  string
	Args []string
}

type Job

type Job struct {
	sync.Mutex
	ID     string
	Status JobStatus
	// contains filtered or unexported fields
}

func NewJob

func NewJob(command Command, logDir string) (*Job, error)

func (*Job) FollowLogs

func (j *Job) FollowLogs() (<-chan string, CancelFunc, error)

func (*Job) Start

func (j *Job) Start() error

func (*Job) Wait

func (j *Job) Wait()

type JobState

type JobState int
const (
	JobStateUnspecified JobState = iota
	JobStatePending
	JobStateRunning
	JobStateCompleted
)

type JobStatus

type JobStatus struct {
	State     JobState
	ExitCode  int
	ExitError error
}

type LogFile

type LogFile struct {
	// contains filtered or unexported fields
}

func NewLogFile

func NewLogFile(filepath string) (*LogFile, error)

func (*LogFile) Close

func (l *LogFile) Close() error

func (*LogFile) Follow

func (l *LogFile) Follow(stopCh <-chan bool) (<-chan string, error)

type Worker

type Worker struct {
	// contains filtered or unexported fields
}

func NewWorker

func NewWorker(logDir string) *Worker

func (*Worker) FollowLogs

func (w *Worker) FollowLogs(jobID string) (<-chan string, CancelFunc, error)

func (*Worker) QueryJob

func (w *Worker) QueryJob(jobID string) (JobStatus, error)

func (*Worker) StartJob

func (w *Worker) StartJob(command Command) (*Job, error)

func (*Worker) StopJob

func (w *Worker) StopJob(jobID string) error

Jump to

Keyboard shortcuts

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