batchs

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: May 24, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTask means a task had a non-zero exit code
	ErrTask = errors.New("error running a task")
)

Functions

func NewFileQueue

func NewFileQueue(basepath string) *fileQueue

NewFileQueue creates a new FileQueue having its state directories at basepath.

func NotImplementedHandler added in v1.1.6

func NotImplementedHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

NotImplementedHandler will return a 501 not implemented error.

Types

type Context

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

Context tracks the path of where we store the queues. It is the only structure which knows about how the queues are persisted to disk. It should be promoted to an interface, probably.

func NewContext

func NewContext(q JobSource, taskpath, version string) *Context

NewContext creates a new context structure. taskpath is used to resolve task names into commands.

func (*Context) Run

func (ctx *Context) Run() error

Run the main event loop forever. Errors are logged. This function never returns.

type Job

type Job struct {
	Todo     []string // FIFO list of task names to execute
	Finished []Task   // list of finished tasks, from earliest to latest
	// contains filtered or unexported fields
}

Job collects all the logical consists of a single processing job. It is, essentially, a list of tasks.

type JobInfo added in v1.1.7

type JobInfo struct {
	Name, Status string
}

type JobSource

type JobSource interface {
	// Perform any initializations
	Init() error
	// Return the next available job. Block until one is available.
	// May return a job AND an error, in which case the job should be finalized.
	NextJob() (*Job, error)
	// Save and finalize the given job
	FinishJob(job *Job) error
}

A JobSource abstracts the way the main processor gets jobs.

type RESTServer added in v1.1.6

type RESTServer struct {
	// Port number to run bendo on. defaults to 15000
	PortNumber string
	QueuePath  *fileQueue
	Version    string
}

RESTServer holds the configuration for a Batch REST API server.

Set all the public fields and then call Run. Run will listen on the given port and handle requests. At the moment there is no maximum simultaneous request limit. Do not change any fields after calling Run.

func (*RESTServer) DeleteJobIdFileHandler added in v1.1.6

func (s *RESTServer) DeleteJobIdFileHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

func (*RESTServer) DeleteJobIdHandler added in v1.1.6

func (s *RESTServer) DeleteJobIdHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

func (*RESTServer) GetJobIdFileHandler added in v1.1.6

func (s *RESTServer) GetJobIdFileHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

func (*RESTServer) GetJobIdHandler added in v1.1.6

func (s *RESTServer) GetJobIdHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

func (*RESTServer) GetJobsHandler added in v1.1.6

func (s *RESTServer) GetJobsHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

GetJobsHandler handles requests to GET /jobs

func (*RESTServer) PutJobIdFileHandler added in v1.1.6

func (s *RESTServer) PutJobIdFileHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

func (*RESTServer) PutJobIdHandler added in v1.1.6

func (s *RESTServer) PutJobIdHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

func (*RESTServer) Run added in v1.1.6

func (s *RESTServer) Run()

Run initializes and starts all the goroutines used by the server. It then blocks listening for and handling http requests. This function never returns.

func (*RESTServer) SubmitJobIdHandler added in v1.1.6

func (s *RESTServer) SubmitJobIdHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

func (*RESTServer) WelcomeHandler added in v1.1.6

func (server *RESTServer) WelcomeHandler(writer http.ResponseWriter, request *http.Request, params httprouter.Params)

Writes the version number to the given writer.

type State

type State int

State encodes the processing status of a Job.

const (
	// StateUnknown is the "zero state"
	StateUnknown State = iota
	// StateQueue means job is awaiting processing
	StateQueue
	// StateProcessing means job is being processed
	StateProcessing
	// StateSuccess means job is finished and was successful
	StateSuccess
	// StateError means job is done being processed and there was an error
	StateError
)

func (State) String

func (s State) String() string

type Task

type Task struct {
	Name   string
	Start  time.Time
	Finish time.Time
	Status string
}

Task is a singular work item inside a Job.

Jump to

Keyboard shortcuts

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