Documentation
¶
Index ¶
- Variables
- func NewFileQueue(basepath string) *fileQueue
- func NotImplementedHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- type Context
- type Job
- type JobInfo
- type JobSource
- type RESTServer
- func (s *RESTServer) DeleteJobIdFileHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (s *RESTServer) DeleteJobIdHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (s *RESTServer) GetJobIdFileHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (s *RESTServer) GetJobIdHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (s *RESTServer) GetJobsHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (s *RESTServer) PutJobIdFileHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (s *RESTServer) PutJobIdHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (s *RESTServer) Run()
- func (s *RESTServer) SubmitJobIdHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (server *RESTServer) WelcomeHandler(writer http.ResponseWriter, request *http.Request, params httprouter.Params)
- type State
- type Task
Constants ¶
This section is empty.
Variables ¶
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 ¶
NewContext creates a new context structure. taskpath is used to resolve task names into commands.
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 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 )