github.com/leg100/ots@v0.0.7-0.20210919080622-034055ced4bd/job.go (about) 1 package ots 2 3 type ErrJobAlreadyStarted error 4 5 // Job represents a piece of work to be done 6 type Job interface { 7 // GetID gets the ID of the job 8 GetID() string 9 // GetStatus gets the status of the job 10 GetStatus() string 11 // Do does the piece of work in an execution environment 12 Do(*Executor) error 13 } 14 15 type JobService interface { 16 // Start is called by an agent when it starts a job. ErrJobAlreadyStarted 17 // should be returned if another agent has already started it. 18 Start(id string, opts JobStartOptions) (Job, error) 19 // Finish is called by an agent when it finishes a job. 20 Finish(id string, opts JobFinishOptions) (Job, error) 21 22 JobLogsUploader 23 } 24 25 type JobLogsUploader interface { 26 // UploadLogs uploads a chunk of output from the job. 27 UploadLogs(id string, logs []byte, opts PutChunkOptions) error 28 } 29 30 type JobStartOptions struct { 31 AgentID string 32 } 33 34 type JobFinishOptions struct { 35 Errored bool 36 }