lib

package
v0.0.0-...-d3090c1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

package lib is a library that provides all the job management utilities for Runner

Index

Constants

This section is empty.

Variables

View Source
var (
	RunnerHome   = "/tmp/runner"
	RootFSSource string // path to the new root file system for jobs
)

TODO: These are global exported variables for now. They should be part of some sort library configuration that can be initialized by the user.

View Source
var Debug = false

Debug enables verbose logging in the library

Functions

This section is empty.

Types

type Job

type Job interface {
	// ID returns the job identifier
	ID() string

	// Stop stops a running job
	Stop()

	// Status returns the status and exit code of the job
	Status() (status JobStatus, exitCode int)

	// Output returns an out channel from which the output of a job can be consumed. The cancel
	// function can be used to stop streaming output from the job. Once cancel function is invoked,
	// the out channel is closed
	Output() (out <-chan *Output, cancel func(), err error)

	// Wait waits for the job to finish
	Wait()
}

Job is the interface that wraps all the functions of a job

func StartJob

func StartJob(config JobConfig) (Job, error)

StartJob starts a new job according to supplied JobConfig

type JobConfig

type JobConfig struct {
	Command string        // Command including arguments to run as a job
	Timeout time.Duration // Timeout determines how long a job is allowed to run
	Profile ResProfile    // Profile determines the resource profile that should be applied to a job
}

JobConfig represents the configuration required to start a job

type JobStatus

type JobStatus int

JobStatus represents the status of a job

const (
	// StatusCreated denotes a newly created job that's not yet started
	StatusCreated JobStatus = iota - 1
	// StatusRunning denotes a job that's in running state
	StatusRunning
	// StatusCompleted denotes a job that ran to its completion
	StatusCompleted
	// StatusStopped denotes a job that was stopped by the caller
	StatusStopped
	// StatusTimedOut denotes a job that was killed due to timeout expiration
	StatusTimedOut
)

func (JobStatus) String

func (s JobStatus) String() string

type Output

type Output struct {
	Bytes []byte
}

Output represents a few bytes of output generated by a job

type ResProfile

type ResProfile string

ResProfile is the name of the resource profile that should be applied to the job

const (
	ResProfileDefault ResProfile = "default"
)

Jump to

Keyboard shortcuts

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