Documentation
¶
Overview ¶
Package controller provides Controller implementation. Controller binds all major components of Weles and provides logic layer for running proper methods of these components.
Controller implements also JobManager interface providing API for controlling Weles' Jobs. This interface should be used by HTTP API server.
Index ¶
- func NewJobManager(arm weles.ArtifactManager, yap weles.Parser, bor boruta.Requests, ...) weles.JobManager
- type Boruter
- type BoruterImpl
- type Controller
- type Downloader
- type DownloaderImpl
- type Dryader
- type DryaderImpl
- type Job
- type JobsController
- type JobsControllerImpl
- func (js *JobsControllerImpl) GetConfig(j weles.JobID) (weles.Config, error)
- func (js *JobsControllerImpl) GetDryad(j weles.JobID) (weles.Dryad, error)
- func (js *JobsControllerImpl) GetYaml(j weles.JobID) ([]byte, error)
- func (js *JobsControllerImpl) List(filter weles.JobFilter, sorter weles.JobSorter, paginator weles.JobPagination) ([]weles.JobInfo, weles.ListInfo, error)
- func (js *JobsControllerImpl) NewJob(yaml []byte) (weles.JobID, error)
- func (js *JobsControllerImpl) SetConfig(j weles.JobID, conf weles.Config) error
- func (js *JobsControllerImpl) SetDryad(j weles.JobID, d weles.Dryad) error
- func (js *JobsControllerImpl) SetStatusAndInfo(j weles.JobID, newStatus weles.JobStatus, msg string) error
- type Parser
- type ParserImpl
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewJobManager ¶
func NewJobManager(arm weles.ArtifactManager, yap weles.Parser, bor boruta.Requests, borutaRefreshPeriod time.Duration, djm weles.DryadJobManager) weles.JobManager
NewJobManager creates and initializes a new instance of Controller with internal submodules and returns JobManager interface. It is the only valid way to get JobManager interface.
Types ¶
type Boruter ¶
type Boruter interface { notifier.Notifier // Request creates request for Dryad and awaits until it is ready, // then acquires it and sends notification. Request(weles.JobID) // Release returns no longer used Dryad to Boruta's pool. Release(weles.JobID) }
Boruter defines actions run for a Job to request and acquire or release Dryad.
func NewBoruter ¶
NewBoruter creates a new BoruterImpl structure setting up references to used Weles and Boruta modules.
type BoruterImpl ¶
type BoruterImpl struct { // Notifier provides channel for communication with Controller. notifier.Notifier // contains filtered or unexported fields }
BoruterImpl is a Handler that is responsible for managing communication with Boruta, acquiring Dryads, prolonging access and releasing them.
func (*BoruterImpl) Release ¶
func (h *BoruterImpl) Release(j weles.JobID)
Release returns Dryad to Boruta's pool and closes Boruta's request.
func (*BoruterImpl) Request ¶
func (h *BoruterImpl) Request(j weles.JobID)
Request registers new request in Boruta and adds it to monitored requests.
type Controller ¶
type Controller struct { weles.JobManager // contains filtered or unexported fields }
Controller binds all major components of Weles and provides logic layer for running proper methods of these components.
It implements JobManager interface providing API for controlling Weles' Jobs. This interface should be used by HTTP API server. Controller should be created with NewController function.
func NewController ¶
func NewController(js JobsController, pa Parser, do Downloader, bo Boruter, dr Dryader, ) *Controller
NewController creates and initializes a new instance of Controller. It requires internal Controller's submodules.
func (*Controller) CancelJob ¶
func (c *Controller) CancelJob(j weles.JobID) error
CancelJob cancels Job identified by argument. Job execution is stopped. It is a part of JobManager implementation.
type Downloader ¶
type Downloader interface { notifier.Notifier // DispatchDownloads requests downloading of artifacts required to start the Job. // It prepares paths for tests results and updates Job's config with artifacts paths. DispatchDownloads(weles.JobID) }
Downloader defines action run for a Job to download artifacts required to run the Job.
func NewDownloader ¶
func NewDownloader(j JobsController, a weles.ArtifactManager) Downloader
NewDownloader creates a new DownloaderImpl structure setting up references to used Weles modules.
type DownloaderImpl ¶
type DownloaderImpl struct { // Notifier provides channel for communication with Controller. notifier.Notifier // contains filtered or unexported fields }
DownloaderImpl implements delegating downloading of artifacts required by Jobs to ArtifactsManager, monitors progress and notifies Controller, when all files are ready.
func (*DownloaderImpl) DispatchDownloads ¶
func (h *DownloaderImpl) DispatchDownloads(j weles.JobID)
DispatchDownloads parses Job's config and delegates to ArtifactManager downloading of all images and files to be pushed during Job execution. It also creates ArtifactDB paths for files that will be pulled from Dryad.
type Dryader ¶
type Dryader interface { notifier.Notifier // StartJob delegates Job execution to DryadJobManager. StartJob(weles.JobID) // CancelJob stops execution of the Job. CancelJob(weles.JobID) }
Dryader defines actions for delegating Jobs to DryadJobManager.
func NewDryader ¶
func NewDryader(j JobsController, d weles.DryadJobManager) Dryader
NewDryader creates a new DryaderImpl structure setting up references to used Weles modules.
type DryaderImpl ¶
type DryaderImpl struct { // Notifier provides channel for communication with Controller. notifier.Notifier // contains filtered or unexported fields }
DryaderImpl implements Dryader. It delegates and controls Job execution by DryadJobManager.
func (*DryaderImpl) CancelJob ¶
func (h *DryaderImpl) CancelJob(j weles.JobID)
CancelJob breaks Job execution in DryadJobManager.
func (*DryaderImpl) StartJob ¶
func (h *DryaderImpl) StartJob(j weles.JobID)
StartJob registers new Job to be executed in DryadJobManager.
type JobsController ¶
type JobsController interface { // NewJob creates a new Job and returns newly assigned JobID. NewJob(yaml []byte) (weles.JobID, error) // GetYaml returns yaml Job description. GetYaml(weles.JobID) ([]byte, error) // SetConfig sets config in Job. SetConfig(weles.JobID, weles.Config) error // SetStatusAndInfo changes status and info of the Job. SetStatusAndInfo(weles.JobID, weles.JobStatus, string) error // GetConfig gets Job's config. GetConfig(weles.JobID) (weles.Config, error) // SetDryad saves access info for acquired Dryad. SetDryad(weles.JobID, weles.Dryad) error // GetDryad returns Dryad acquired for the Job. GetDryad(weles.JobID) (weles.Dryad, error) // List returns information on Jobs. It takes 3 arguments: // - JobFilter containing filters // - JobSorter containing sorting key and sorting direction // - JobPagination containing element after/before which a page should be returned. It also // contains information about direction of pagination and the size of the returned page which // must always be set. List(filter weles.JobFilter, sorter weles.JobSorter, paginator weles.JobPagination) ([]weles.JobInfo, weles.ListInfo, error) // nolint: lll }
JobsController defines methods for Jobs structures operations inside Controller.
func NewJobsController ¶
func NewJobsController() JobsController
NewJobsController creates and initializes a new instance of Jobs structure. It is the only valid way of creating it.
type JobsControllerImpl ¶
type JobsControllerImpl struct { JobsController // contains filtered or unexported fields }
JobsControllerImpl structure stores Weles' Jobs data. It controls collision-free JobID creation. It stores state of Jobs' execution and saves data to DB. It implements JobsController interface.
func (*JobsControllerImpl) GetYaml ¶
func (js *JobsControllerImpl) GetYaml(j weles.JobID) ([]byte, error)
GetYaml returns yaml Job description.
func (*JobsControllerImpl) List ¶
func (js *JobsControllerImpl) List(filter weles.JobFilter, sorter weles.JobSorter, paginator weles.JobPagination) ([]weles.JobInfo, weles.ListInfo, error)
List returns information on Jobs. It takes 3 arguments: - JobFilter containing filters - JobSorter containing sorting key and sorting direction - JobPagination containing element after/before which a page should be returned. It also contains information about direction of listing and the size of the returned page which must always be set.
func (*JobsControllerImpl) NewJob ¶
func (js *JobsControllerImpl) NewJob(yaml []byte) (weles.JobID, error)
NewJob creates and initializes a new Job.
func (*JobsControllerImpl) SetStatusAndInfo ¶
func (js *JobsControllerImpl) SetStatusAndInfo(j weles.JobID, newStatus weles.JobStatus, msg string, ) error
SetStatusAndInfo changes status of the Job and updates info. Only valid changes are allowed. There are 3 terminal statuses: JobStatusFAILED, JobStatusCANCELED, JobStatusCOMPLETED; and 5 non-terminal statuses: JobStatusNEW, JobStatusPARSING, JobStatusDOWNLOADING, JobStatusWAITING, JobStatusRUNNING. Only below changes of statuses are allowed: * JobStatusNEW --> {JobStatusPARSING, JobStatusCANCELED, JobStatusFAILED} * JobStatusPARSING --> {JobStatusDOWNLOADING, JobStatusCANCELED, JobStatusFAILED} * JobStatusDOWNLOADING --> {JobStatusWAITING, JobStatusCANCELED, JobStatusFAILED} * JobStatusWAITING --> {JobStatusRUNNING, JobStatusCANCELED, JobStatusFAILED} * JobStatusRUNNING --> {JobStatusCOMPLETED, JobStatusCANCELED, JobStatusFAILED}
type Parser ¶
Parser defines action run for a Job to prepare config in parsing phase.
func NewParser ¶
func NewParser(j JobsController, a weles.ArtifactManager, p weles.Parser) Parser
NewParser creates a new ParserImpl structure setting up references to Weles' modules.
type ParserImpl ¶
type ParserImpl struct { // Notifier provides channel for communication with Controller. notifier.Notifier // contains filtered or unexported fields }
ParserImpl implements Parser for Controller.
func (*ParserImpl) Parse ¶
func (h *ParserImpl) Parse(j weles.JobID)
Parse prepares new Job to be processed by saving yaml file in ArtifactDB, parsing yaml and preparing Job's configuration.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package mock is a generated GoMock package.
|
Package mock is a generated GoMock package. |
Package notifier defines structures and constants used by controller package and provides Notifier interface with implementation for communication between submodules and Controller.
|
Package notifier defines structures and constants used by controller package and provides Notifier interface with implementation for communication between submodules and Controller. |