Documentation ¶
Index ¶
- Variables
- func InitWSContainer() *restful.Container
- func SendWebhook(job Job)
- type Cmd
- type CmdResult
- type Container
- type DockerEventListener
- type ImageName
- type Job
- type JobAPI
- type JobID
- type JobManager
- type JobService
- type JobStatus
- type JobStore
- type JobUpdater
- type LogService
- type StopEventListener
- type StopService
Constants ¶
This section is empty.
Variables ¶
var ( // ErrJobNotFound indicates the specificed job // could not be found ErrJobNotFound = fmt.Errorf("No job with that ID") // ErrInvalidJobID indicates the job ID was // specificed in an invalid format ErrInvalidJobID = fmt.Errorf("Invalid job ID") )
Functions ¶
func InitWSContainer ¶
func InitWSContainer() *restful.Container
InitWSContainer sets up the program
func SendWebhook ¶
func SendWebhook(job Job)
SendWebhook performs the webhook request for the given Job
Types ¶
type DockerEventListener ¶
type DockerEventListener interface { Start() error Stop() RegisterListener(listener chan *docker.APIEvents) UnregisterListener(listener chan *docker.APIEvents) }
DockerEventListener wraps the underlying Docker event listener
func NewEventListener ¶
func NewEventListener(client *docker.Client) DockerEventListener
NewEventListener returns a new EventListener
type Job ¶
type Job struct { ID JobID `json:"id"` ImageName string `json:"image"` Env map[string]string `json:"env"` Status JobStatus `json:"status"` Cmds []Cmd `json:"cmds"` Message string `json:"message"` Results []CmdResult `json:"results"` Containers []Container `json:"containers"` Images []ImageName `json:"images"` WebhookURL string `json:"webhook_url"` StartTime time.Time `json:"start_time"` EndTime time.Time `json:"end_time"` }
Job is a job
type JobAPI ¶
type JobAPI struct {
// contains filtered or unexported fields
}
JobAPI is a jobs api
func NewJobAPI ¶
func NewJobAPI(jobService JobService, logService LogService, stopService StopService) JobAPI
NewJobAPI creates a new JobAPI
type JobManager ¶
type JobManager interface { NotifyNewJob(job Job) Start() Stop() }
JobManager manages Jobs
func NewJobManager ¶
func NewJobManager(jobStore JobStore, client *docker.Client, eventListner DockerEventListener, jobUpdater JobUpdater, stopEventListener StopEventListener) JobManager
NewJobManager returns a new JobManager
type JobService ¶
type JobService interface { Add(job Job) (Job, error) Find(ID JobID) (Job, error) UpdateStatus(job Job) error }
JobService handles the jobs
func NewJobService ¶
func NewJobService(jobStore JobStore, jobManager JobManager) JobService
NewJobService returns a new JobService
type JobStatus ¶
type JobStatus string
JobStatus represents the status of the Job
const ( // JobStatusQueued state indicates the job is queued waiting to be run JobStatusQueued JobStatus = "queued" // JobStatusRunning state indicates the job is running JobStatusRunning JobStatus = "running" // JobStatusSuccessful state indicates the job has completed successfully JobStatusSuccessful JobStatus = "successful" // JobStatusFailed state indicates the job has completed with a failure JobStatusFailed JobStatus = "failed" // JobStatusError state indicates the job could not be run properly JobStatusError JobStatus = "error" // JobStatusStopped state indicates the job was stoped JobStatusStopped JobStatus = "stopped" )
type JobStore ¶
type JobStore interface { Add(job Job) (Job, error) Find(ID JobID) (Job, error) Update(job Job) error }
JobStore stores jobs
type JobUpdater ¶
type JobUpdater interface { UpdateStatus(job *Job, status JobStatus) error UpdateStartTime(job *Job, startTime time.Time) error UpdateEndTime(job *Job, endTime time.Time) error AddCmdResult(job *Job, result CmdResult) error AddContainer(job *Job, container Container) error AddImage(job *Job, image ImageName) error }
JobUpdater handles updating jobs
func NewJobUpdater ¶
func NewJobUpdater(jobStore JobStore) JobUpdater
NewJobUpdater returns a new JobUpdater
type LogService ¶
LogService handles retrieving logs from containers
func NewLogService ¶
func NewLogService(jobStore JobStore, client *docker.Client) LogService
NewLogService returns a new LogService
type StopEventListener ¶
type StopEventListener interface { Start() error Stop() RegisterListener(listener chan JobID) UnregisterListener(listener chan JobID) }
StopEventListener handles requests to stop running jobs
func NewStopEventListener ¶
func NewStopEventListener(stopEventChan chan JobID) StopEventListener
NewStopEventListener returns a new StopEventListener
type StopService ¶
StopService handles stopping jobs
func NewStopService ¶
func NewStopService(stopEventChan chan JobID) StopService
NewStopService returns a new StopService